Skip to content

Commit a51482b

Browse files
Jesper Juhldavem330
authored andcommitted
[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: Jesper Juhl <jesper.juhl@gmail.com> Cc: "David S. Miller" <davem@davemloft.net> Cc: Arnaldo Carvalho de Melo <acme@conectiva.com.br> Acked-by: Marcel Holtmann <marcel@holtmann.org> Acked-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org> Signed-off-by: Andrew Morton <akpm@osdl.org>
1 parent ac7c98e commit a51482b

47 files changed

Lines changed: 99 additions & 191 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎net/802/p8023.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ struct datalink_proto *make_8023_client(void)
5454
*/
5555
void destroy_8023_client(struct datalink_proto *dl)
5656
{
57-
if (dl)
58-
kfree(dl);
57+
kfree(dl);
5958
}
6059

6160
EXPORT_SYMBOL(destroy_8023_client);

‎net/ax25/af_ax25.c‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,10 +1138,8 @@ static int ax25_connect(struct socket *sock, struct sockaddr *uaddr,
11381138
sk->sk_state = TCP_CLOSE;
11391139
sock->state = SS_UNCONNECTED;
11401140

1141-
if (ax25->digipeat != NULL) {
1142-
kfree(ax25->digipeat);
1143-
ax25->digipeat = NULL;
1144-
}
1141+
kfree(ax25->digipeat);
1142+
ax25->digipeat = NULL;
11451143

11461144
/*
11471145
* Handle digi-peaters to be used.

‎net/ax25/ax25_in.c‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -401,10 +401,8 @@ static int ax25_rcv(struct sk_buff *skb, struct net_device *dev,
401401
}
402402

403403
if (dp.ndigi == 0) {
404-
if (ax25->digipeat != NULL) {
405-
kfree(ax25->digipeat);
406-
ax25->digipeat = NULL;
407-
}
404+
kfree(ax25->digipeat);
405+
ax25->digipeat = NULL;
408406
} else {
409407
/* Reverse the source SABM's path */
410408
memcpy(ax25->digipeat, &reverse_dp, sizeof(ax25_digi));

‎net/ax25/ax25_route.c‎

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,13 @@ void ax25_rt_device_down(struct net_device *dev)
5454
if (s->dev == dev) {
5555
if (ax25_route_list == s) {
5656
ax25_route_list = s->next;
57-
if (s->digipeat != NULL)
58-
kfree(s->digipeat);
57+
kfree(s->digipeat);
5958
kfree(s);
6059
} else {
6160
for (t = ax25_route_list; t != NULL; t = t->next) {
6261
if (t->next == s) {
6362
t->next = s->next;
64-
if (s->digipeat != NULL)
65-
kfree(s->digipeat);
63+
kfree(s->digipeat);
6664
kfree(s);
6765
break;
6866
}
@@ -90,10 +88,8 @@ static int ax25_rt_add(struct ax25_routes_struct *route)
9088
while (ax25_rt != NULL) {
9189
if (ax25cmp(&ax25_rt->callsign, &route->dest_addr) == 0 &&
9290
ax25_rt->dev == ax25_dev->dev) {
93-
if (ax25_rt->digipeat != NULL) {
94-
kfree(ax25_rt->digipeat);
95-
ax25_rt->digipeat = NULL;
96-
}
91+
kfree(ax25_rt->digipeat);
92+
ax25_rt->digipeat = NULL;
9793
if (route->digi_count != 0) {
9894
if ((ax25_rt->digipeat = kmalloc(sizeof(ax25_digi), GFP_ATOMIC)) == NULL) {
9995
write_unlock(&ax25_route_lock);
@@ -145,8 +141,7 @@ static int ax25_rt_add(struct ax25_routes_struct *route)
145141
static void ax25_rt_destroy(ax25_route *ax25_rt)
146142
{
147143
if (atomic_read(&ax25_rt->ref) == 0) {
148-
if (ax25_rt->digipeat != NULL)
149-
kfree(ax25_rt->digipeat);
144+
kfree(ax25_rt->digipeat);
150145
kfree(ax25_rt);
151146
return;
152147
}
@@ -530,9 +525,7 @@ void __exit ax25_rt_free(void)
530525
s = ax25_rt;
531526
ax25_rt = ax25_rt->next;
532527

533-
if (s->digipeat != NULL)
534-
kfree(s->digipeat);
535-
528+
kfree(s->digipeat);
536529
kfree(s);
537530
}
538531
write_unlock(&ax25_route_lock);

‎net/bluetooth/hidp/core.c‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -660,9 +660,7 @@ int hidp_add_connection(struct hidp_connadd_req *req, struct socket *ctrl_sock,
660660
failed:
661661
up_write(&hidp_session_sem);
662662

663-
if (session->input)
664-
kfree(session->input);
665-
663+
kfree(session->input);
666664
kfree(session);
667665
return err;
668666
}

‎net/core/dev_mcast.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,7 @@ int dev_mc_add(struct net_device *dev, void *addr, int alen, int glbl)
194194

195195
done:
196196
spin_unlock_bh(&dev->xmit_lock);
197-
if (dmi1)
198-
kfree(dmi1);
197+
kfree(dmi1);
199198
return err;
200199
}
201200

‎net/core/sock.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,8 +1242,7 @@ static void sock_def_write_space(struct sock *sk)
12421242

12431243
static void sock_def_destruct(struct sock *sk)
12441244
{
1245-
if (sk->sk_protinfo)
1246-
kfree(sk->sk_protinfo);
1245+
kfree(sk->sk_protinfo);
12471246
}
12481247

12491248
void sk_send_sigurg(struct sock *sk)

‎net/dccp/ipv4.c‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,10 +1263,8 @@ static int dccp_v4_destroy_sock(struct sock *sk)
12631263
if (inet_csk(sk)->icsk_bind_hash != NULL)
12641264
inet_put_port(&dccp_hashinfo, sk);
12651265

1266-
if (dp->dccps_service_list != NULL) {
1267-
kfree(dp->dccps_service_list);
1268-
dp->dccps_service_list = NULL;
1269-
}
1266+
kfree(dp->dccps_service_list);
1267+
dp->dccps_service_list = NULL;
12701268

12711269
ccid_hc_rx_exit(dp->dccps_hc_rx_ccid, sk);
12721270
ccid_hc_tx_exit(dp->dccps_hc_tx_ccid, sk);

‎net/dccp/proto.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,7 @@ static int dccp_setsockopt_service(struct sock *sk, const u32 service,
238238
lock_sock(sk);
239239
dp->dccps_service = service;
240240

241-
if (dp->dccps_service_list != NULL)
242-
kfree(dp->dccps_service_list);
241+
kfree(dp->dccps_service_list);
243242

244243
dp->dccps_service_list = sl;
245244
release_sock(sk);

‎net/decnet/dn_table.c‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -784,16 +784,14 @@ struct dn_fib_table *dn_fib_get_table(int n, int create)
784784

785785
static void dn_fib_del_tree(int n)
786786
{
787-
struct dn_fib_table *t;
787+
struct dn_fib_table *t;
788788

789-
write_lock(&dn_fib_tables_lock);
790-
t = dn_fib_tables[n];
791-
dn_fib_tables[n] = NULL;
792-
write_unlock(&dn_fib_tables_lock);
789+
write_lock(&dn_fib_tables_lock);
790+
t = dn_fib_tables[n];
791+
dn_fib_tables[n] = NULL;
792+
write_unlock(&dn_fib_tables_lock);
793793

794-
if (t) {
795-
kfree(t);
796-
}
794+
kfree(t);
797795
}
798796

799797
struct dn_fib_table *dn_fib_empty_table(void)

0 commit comments

Comments
 (0)