Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a51482bd authored by Jesper Juhl's avatar Jesper Juhl Committed by David S. Miller
Browse files

[NET]: kfree cleanup



From: Jesper Juhl <jesper.juhl@gmail.com>

This is the net/ part of the big kfree cleanup patch.

Remove pointless checks for NULL prior to calling kfree() in net/.

Signed-off-by: default avatarJesper Juhl <jesper.juhl@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Arnaldo Carvalho de Melo <acme@conectiva.com.br>
Acked-by: default avatarMarcel Holtmann <marcel@holtmann.org>
Acked-by: default avatarYOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
parent ac7c98ec
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -54,7 +54,6 @@ struct datalink_proto *make_8023_client(void)
 */
void destroy_8023_client(struct datalink_proto *dl)
{
	if (dl)
	kfree(dl);
}

+2 −4
Original line number Diff line number Diff line
@@ -1138,10 +1138,8 @@ static int ax25_connect(struct socket *sock, struct sockaddr *uaddr,
	sk->sk_state   = TCP_CLOSE;
	sock->state = SS_UNCONNECTED;

	if (ax25->digipeat != NULL) {
	kfree(ax25->digipeat);
	ax25->digipeat = NULL;
	}

	/*
	 *	Handle digi-peaters to be used.
+2 −4
Original line number Diff line number Diff line
@@ -401,10 +401,8 @@ static int ax25_rcv(struct sk_buff *skb, struct net_device *dev,
	}

	if (dp.ndigi == 0) {
		if (ax25->digipeat != NULL) {
		kfree(ax25->digipeat);
		ax25->digipeat = NULL;
		}
	} else {
		/* Reverse the source SABM's path */
		memcpy(ax25->digipeat, &reverse_dp, sizeof(ax25_digi));
+6 −13
Original line number Diff line number Diff line
@@ -54,14 +54,12 @@ void ax25_rt_device_down(struct net_device *dev)
		if (s->dev == dev) {
			if (ax25_route_list == s) {
				ax25_route_list = s->next;
				if (s->digipeat != NULL)
				kfree(s->digipeat);
				kfree(s);
			} else {
				for (t = ax25_route_list; t != NULL; t = t->next) {
					if (t->next == s) {
						t->next = s->next;
						if (s->digipeat != NULL)
						kfree(s->digipeat);
						kfree(s);
						break;
@@ -90,10 +88,8 @@ static int ax25_rt_add(struct ax25_routes_struct *route)
	while (ax25_rt != NULL) {
		if (ax25cmp(&ax25_rt->callsign, &route->dest_addr) == 0 &&
		            ax25_rt->dev == ax25_dev->dev) {
			if (ax25_rt->digipeat != NULL) {
			kfree(ax25_rt->digipeat);
			ax25_rt->digipeat = NULL;
			}
			if (route->digi_count != 0) {
				if ((ax25_rt->digipeat = kmalloc(sizeof(ax25_digi), GFP_ATOMIC)) == NULL) {
					write_unlock(&ax25_route_lock);
@@ -145,7 +141,6 @@ static int ax25_rt_add(struct ax25_routes_struct *route)
static void ax25_rt_destroy(ax25_route *ax25_rt)
{
	if (atomic_read(&ax25_rt->ref) == 0) {
		if (ax25_rt->digipeat != NULL)
		kfree(ax25_rt->digipeat);
		kfree(ax25_rt);
		return;
@@ -530,9 +525,7 @@ void __exit ax25_rt_free(void)
		s       = ax25_rt;
		ax25_rt = ax25_rt->next;

		if (s->digipeat != NULL)
		kfree(s->digipeat);

		kfree(s);
	}
	write_unlock(&ax25_route_lock);
+1 −3
Original line number Diff line number Diff line
@@ -660,9 +660,7 @@ int hidp_add_connection(struct hidp_connadd_req *req, struct socket *ctrl_sock,
failed:
	up_write(&hidp_session_sem);

	if (session->input)
	kfree(session->input);

	kfree(session);
	return err;
}
Loading