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

[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
...@@ -54,8 +54,7 @@ struct datalink_proto *make_8023_client(void) ...@@ -54,8 +54,7 @@ struct datalink_proto *make_8023_client(void)
*/ */
void destroy_8023_client(struct datalink_proto *dl) void destroy_8023_client(struct datalink_proto *dl)
{ {
if (dl) kfree(dl);
kfree(dl);
} }
EXPORT_SYMBOL(destroy_8023_client); EXPORT_SYMBOL(destroy_8023_client);
......
...@@ -1138,10 +1138,8 @@ static int ax25_connect(struct socket *sock, struct sockaddr *uaddr, ...@@ -1138,10 +1138,8 @@ static int ax25_connect(struct socket *sock, struct sockaddr *uaddr,
sk->sk_state = TCP_CLOSE; sk->sk_state = TCP_CLOSE;
sock->state = SS_UNCONNECTED; sock->state = SS_UNCONNECTED;
if (ax25->digipeat != NULL) { kfree(ax25->digipeat);
kfree(ax25->digipeat); ax25->digipeat = NULL;
ax25->digipeat = NULL;
}
/* /*
* Handle digi-peaters to be used. * Handle digi-peaters to be used.
......
...@@ -401,10 +401,8 @@ static int ax25_rcv(struct sk_buff *skb, struct net_device *dev, ...@@ -401,10 +401,8 @@ static int ax25_rcv(struct sk_buff *skb, struct net_device *dev,
} }
if (dp.ndigi == 0) { if (dp.ndigi == 0) {
if (ax25->digipeat != NULL) { kfree(ax25->digipeat);
kfree(ax25->digipeat); ax25->digipeat = NULL;
ax25->digipeat = NULL;
}
} else { } else {
/* Reverse the source SABM's path */ /* Reverse the source SABM's path */
memcpy(ax25->digipeat, &reverse_dp, sizeof(ax25_digi)); memcpy(ax25->digipeat, &reverse_dp, sizeof(ax25_digi));
......
...@@ -54,15 +54,13 @@ void ax25_rt_device_down(struct net_device *dev) ...@@ -54,15 +54,13 @@ void ax25_rt_device_down(struct net_device *dev)
if (s->dev == dev) { if (s->dev == dev) {
if (ax25_route_list == s) { if (ax25_route_list == s) {
ax25_route_list = s->next; ax25_route_list = s->next;
if (s->digipeat != NULL) kfree(s->digipeat);
kfree(s->digipeat);
kfree(s); kfree(s);
} else { } else {
for (t = ax25_route_list; t != NULL; t = t->next) { for (t = ax25_route_list; t != NULL; t = t->next) {
if (t->next == s) { if (t->next == s) {
t->next = s->next; t->next = s->next;
if (s->digipeat != NULL) kfree(s->digipeat);
kfree(s->digipeat);
kfree(s); kfree(s);
break; break;
} }
...@@ -90,10 +88,8 @@ static int ax25_rt_add(struct ax25_routes_struct *route) ...@@ -90,10 +88,8 @@ static int ax25_rt_add(struct ax25_routes_struct *route)
while (ax25_rt != NULL) { while (ax25_rt != NULL) {
if (ax25cmp(&ax25_rt->callsign, &route->dest_addr) == 0 && if (ax25cmp(&ax25_rt->callsign, &route->dest_addr) == 0 &&
ax25_rt->dev == ax25_dev->dev) { ax25_rt->dev == ax25_dev->dev) {
if (ax25_rt->digipeat != NULL) { kfree(ax25_rt->digipeat);
kfree(ax25_rt->digipeat); ax25_rt->digipeat = NULL;
ax25_rt->digipeat = NULL;
}
if (route->digi_count != 0) { if (route->digi_count != 0) {
if ((ax25_rt->digipeat = kmalloc(sizeof(ax25_digi), GFP_ATOMIC)) == NULL) { if ((ax25_rt->digipeat = kmalloc(sizeof(ax25_digi), GFP_ATOMIC)) == NULL) {
write_unlock(&ax25_route_lock); write_unlock(&ax25_route_lock);
...@@ -145,8 +141,7 @@ static int ax25_rt_add(struct ax25_routes_struct *route) ...@@ -145,8 +141,7 @@ static int ax25_rt_add(struct ax25_routes_struct *route)
static void ax25_rt_destroy(ax25_route *ax25_rt) static void ax25_rt_destroy(ax25_route *ax25_rt)
{ {
if (atomic_read(&ax25_rt->ref) == 0) { if (atomic_read(&ax25_rt->ref) == 0) {
if (ax25_rt->digipeat != NULL) kfree(ax25_rt->digipeat);
kfree(ax25_rt->digipeat);
kfree(ax25_rt); kfree(ax25_rt);
return; return;
} }
...@@ -530,9 +525,7 @@ void __exit ax25_rt_free(void) ...@@ -530,9 +525,7 @@ void __exit ax25_rt_free(void)
s = ax25_rt; s = ax25_rt;
ax25_rt = ax25_rt->next; ax25_rt = ax25_rt->next;
if (s->digipeat != NULL) kfree(s->digipeat);
kfree(s->digipeat);
kfree(s); kfree(s);
} }
write_unlock(&ax25_route_lock); write_unlock(&ax25_route_lock);
......
...@@ -660,9 +660,7 @@ int hidp_add_connection(struct hidp_connadd_req *req, struct socket *ctrl_sock, ...@@ -660,9 +660,7 @@ int hidp_add_connection(struct hidp_connadd_req *req, struct socket *ctrl_sock,
failed: failed:
up_write(&hidp_session_sem); up_write(&hidp_session_sem);
if (session->input) kfree(session->input);
kfree(session->input);
kfree(session); kfree(session);
return err; return err;
} }
......
...@@ -194,8 +194,7 @@ int dev_mc_add(struct net_device *dev, void *addr, int alen, int glbl) ...@@ -194,8 +194,7 @@ int dev_mc_add(struct net_device *dev, void *addr, int alen, int glbl)
done: done:
spin_unlock_bh(&dev->xmit_lock); spin_unlock_bh(&dev->xmit_lock);
if (dmi1) kfree(dmi1);
kfree(dmi1);
return err; return err;
} }
......
...@@ -1242,8 +1242,7 @@ static void sock_def_write_space(struct sock *sk) ...@@ -1242,8 +1242,7 @@ static void sock_def_write_space(struct sock *sk)
static void sock_def_destruct(struct sock *sk) static void sock_def_destruct(struct sock *sk)
{ {
if (sk->sk_protinfo) kfree(sk->sk_protinfo);
kfree(sk->sk_protinfo);
} }
void sk_send_sigurg(struct sock *sk) void sk_send_sigurg(struct sock *sk)
......
...@@ -1263,10 +1263,8 @@ static int dccp_v4_destroy_sock(struct sock *sk) ...@@ -1263,10 +1263,8 @@ static int dccp_v4_destroy_sock(struct sock *sk)
if (inet_csk(sk)->icsk_bind_hash != NULL) if (inet_csk(sk)->icsk_bind_hash != NULL)
inet_put_port(&dccp_hashinfo, sk); inet_put_port(&dccp_hashinfo, sk);
if (dp->dccps_service_list != NULL) { kfree(dp->dccps_service_list);
kfree(dp->dccps_service_list); dp->dccps_service_list = NULL;
dp->dccps_service_list = NULL;
}
ccid_hc_rx_exit(dp->dccps_hc_rx_ccid, sk); ccid_hc_rx_exit(dp->dccps_hc_rx_ccid, sk);
ccid_hc_tx_exit(dp->dccps_hc_tx_ccid, sk); ccid_hc_tx_exit(dp->dccps_hc_tx_ccid, sk);
......
...@@ -238,8 +238,7 @@ static int dccp_setsockopt_service(struct sock *sk, const u32 service, ...@@ -238,8 +238,7 @@ static int dccp_setsockopt_service(struct sock *sk, const u32 service,
lock_sock(sk); lock_sock(sk);
dp->dccps_service = service; dp->dccps_service = service;
if (dp->dccps_service_list != NULL) kfree(dp->dccps_service_list);
kfree(dp->dccps_service_list);
dp->dccps_service_list = sl; dp->dccps_service_list = sl;
release_sock(sk); release_sock(sk);
......
...@@ -784,16 +784,14 @@ struct dn_fib_table *dn_fib_get_table(int n, int create) ...@@ -784,16 +784,14 @@ struct dn_fib_table *dn_fib_get_table(int n, int create)
static void dn_fib_del_tree(int n) static void dn_fib_del_tree(int n)
{ {
struct dn_fib_table *t; struct dn_fib_table *t;
write_lock(&dn_fib_tables_lock); write_lock(&dn_fib_tables_lock);
t = dn_fib_tables[n]; t = dn_fib_tables[n];
dn_fib_tables[n] = NULL; dn_fib_tables[n] = NULL;
write_unlock(&dn_fib_tables_lock); write_unlock(&dn_fib_tables_lock);
if (t) { kfree(t);
kfree(t);
}
} }
struct dn_fib_table *dn_fib_empty_table(void) struct dn_fib_table *dn_fib_empty_table(void)
......
...@@ -32,8 +32,7 @@ struct datalink_proto *make_EII_client(void) ...@@ -32,8 +32,7 @@ struct datalink_proto *make_EII_client(void)
void destroy_EII_client(struct datalink_proto *dl) void destroy_EII_client(struct datalink_proto *dl)
{ {
if (dl) kfree(dl);
kfree(dl);
} }
EXPORT_SYMBOL(destroy_EII_client); EXPORT_SYMBOL(destroy_EII_client);
......
...@@ -147,8 +147,7 @@ void inet_sock_destruct(struct sock *sk) ...@@ -147,8 +147,7 @@ void inet_sock_destruct(struct sock *sk)
BUG_TRAP(!sk->sk_wmem_queued); BUG_TRAP(!sk->sk_wmem_queued);
BUG_TRAP(!sk->sk_forward_alloc); BUG_TRAP(!sk->sk_forward_alloc);
if (inet->opt) kfree(inet->opt);
kfree(inet->opt);
dst_release(sk->sk_dst_cache); dst_release(sk->sk_dst_cache);
sk_refcnt_debug_dec(sk); sk_refcnt_debug_dec(sk);
} }
......
...@@ -266,8 +266,7 @@ int ip_rt_ioctl(unsigned int cmd, void __user *arg) ...@@ -266,8 +266,7 @@ int ip_rt_ioctl(unsigned int cmd, void __user *arg)
if (tb) if (tb)
err = tb->tb_insert(tb, &req.rtm, &rta, &req.nlh, NULL); err = tb->tb_insert(tb, &req.rtm, &rta, &req.nlh, NULL);
} }
if (rta.rta_mx) kfree(rta.rta_mx);
kfree(rta.rta_mx);
} }
rtnl_unlock(); rtnl_unlock();
return err; return err;
......
...@@ -510,8 +510,7 @@ static int ip_options_get_finish(struct ip_options **optp, ...@@ -510,8 +510,7 @@ static int ip_options_get_finish(struct ip_options **optp,
kfree(opt); kfree(opt);
return -EINVAL; return -EINVAL;
} }
if (*optp) kfree(*optp);
kfree(*optp);
*optp = opt; *optp = opt;
return 0; return 0;
} }
......
...@@ -1262,10 +1262,8 @@ int ip_push_pending_frames(struct sock *sk) ...@@ -1262,10 +1262,8 @@ int ip_push_pending_frames(struct sock *sk)
out: out:
inet->cork.flags &= ~IPCORK_OPT; inet->cork.flags &= ~IPCORK_OPT;
if (inet->cork.opt) { kfree(inet->cork.opt);
kfree(inet->cork.opt); inet->cork.opt = NULL;
inet->cork.opt = NULL;
}
if (inet->cork.rt) { if (inet->cork.rt) {
ip_rt_put(inet->cork.rt); ip_rt_put(inet->cork.rt);
inet->cork.rt = NULL; inet->cork.rt = NULL;
...@@ -1289,10 +1287,8 @@ void ip_flush_pending_frames(struct sock *sk) ...@@ -1289,10 +1287,8 @@ void ip_flush_pending_frames(struct sock *sk)
kfree_skb(skb); kfree_skb(skb);
inet->cork.flags &= ~IPCORK_OPT; inet->cork.flags &= ~IPCORK_OPT;
if (inet->cork.opt) { kfree(inet->cork.opt);
kfree(inet->cork.opt); inet->cork.opt = NULL;
inet->cork.opt = NULL;
}
if (inet->cork.rt) { if (inet->cork.rt) {
ip_rt_put(inet->cork.rt); ip_rt_put(inet->cork.rt);
inet->cork.rt = NULL; inet->cork.rt = NULL;
......
...@@ -202,8 +202,7 @@ int ip_ra_control(struct sock *sk, unsigned char on, void (*destructor)(struct s ...@@ -202,8 +202,7 @@ int ip_ra_control(struct sock *sk, unsigned char on, void (*destructor)(struct s
if (ra->sk == sk) { if (ra->sk == sk) {
if (on) { if (on) {
write_unlock_bh(&ip_ra_lock); write_unlock_bh(&ip_ra_lock);
if (new_ra) kfree(new_ra);
kfree(new_ra);
return -EADDRINUSE; return -EADDRINUSE;
} }
*rap = ra->next; *rap = ra->next;
...@@ -446,8 +445,7 @@ int ip_setsockopt(struct sock *sk, int level, int optname, char __user *optval, ...@@ -446,8 +445,7 @@ int ip_setsockopt(struct sock *sk, int level, int optname, char __user *optval,
#endif #endif
} }
opt = xchg(&inet->opt, opt); opt = xchg(&inet->opt, opt);
if (opt) kfree(opt);
kfree(opt);
break; break;
} }
case IP_PKTINFO: case IP_PKTINFO:
...@@ -828,10 +826,8 @@ int ip_setsockopt(struct sock *sk, int level, int optname, char __user *optval, ...@@ -828,10 +826,8 @@ int ip_setsockopt(struct sock *sk, int level, int optname, char __user *optval,
err = ip_mc_msfilter(sk, msf, ifindex); err = ip_mc_msfilter(sk, msf, ifindex);
mc_msf_out: mc_msf_out:
if (msf) kfree(msf);
kfree(msf); kfree(gsf);
if (gsf)
kfree(gsf);
break; break;
} }
case IP_ROUTER_ALERT: case IP_ROUTER_ALERT:
......
...@@ -110,8 +110,7 @@ ip_vs_app_inc_new(struct ip_vs_app *app, __u16 proto, __u16 port) ...@@ -110,8 +110,7 @@ ip_vs_app_inc_new(struct ip_vs_app *app, __u16 proto, __u16 port)
return 0; return 0;
out: out:
if (inc->timeout_table) kfree(inc->timeout_table);
kfree(inc->timeout_table);
kfree(inc); kfree(inc);
return ret; return ret;
} }
...@@ -136,8 +135,7 @@ ip_vs_app_inc_release(struct ip_vs_app *inc) ...@@ -136,8 +135,7 @@ ip_vs_app_inc_release(struct ip_vs_app *inc)
list_del(&inc->a_list); list_del(&inc->a_list);
if (inc->timeout_table != NULL) kfree(inc->timeout_table);
kfree(inc->timeout_table);
kfree(inc); kfree(inc);
} }
......
...@@ -207,16 +207,12 @@ static void wrandom_select_route(const struct flowi *flp, ...@@ -207,16 +207,12 @@ static void wrandom_select_route(const struct flowi *flp,
decision = mpc->rt; decision = mpc->rt;
last_power = mpc->power; last_power = mpc->power;
if (last_mpc) kfree(last_mpc);
kfree(last_mpc);
last_mpc = mpc; last_mpc = mpc;
} }
if (last_mpc) { /* concurrent __multipath_flush may lead to !last_mpc */
/* concurrent __multipath_flush may lead to !last_mpc */ kfree(last_mpc);
kfree(last_mpc);
}
decision->u.dst.__use++; decision->u.dst.__use++;
*rp = decision; *rp = decision;
......
...@@ -1161,8 +1161,7 @@ static int snmp_parse_mangle(unsigned char *msg, ...@@ -1161,8 +1161,7 @@ static int snmp_parse_mangle(unsigned char *msg,
if (!snmp_object_decode(&ctx, obj)) { if (!snmp_object_decode(&ctx, obj)) {
if (*obj) { if (*obj) {
if ((*obj)->id) kfree((*obj)->id);
kfree((*obj)->id);
kfree(*obj); kfree(*obj);
} }
kfree(obj); kfree(obj);
......
...@@ -823,8 +823,7 @@ static int tcp_v4_send_synack(struct sock *sk, struct request_sock *req, ...@@ -823,8 +823,7 @@ static int tcp_v4_send_synack(struct sock *sk, struct request_sock *req,
*/ */
static void tcp_v4_reqsk_destructor(struct request_sock *req) static void tcp_v4_reqsk_destructor(struct request_sock *req)
{ {
if (inet_rsk(req)->opt) kfree(inet_rsk(req)->opt);
kfree(inet_rsk(req)->opt);
} }
static inline void syn_flood_warning(struct sk_buff *skb) static inline void syn_flood_warning(struct sk_buff *skb)
......
...@@ -3090,8 +3090,7 @@ static int inet6_fill_ifinfo(struct sk_buff *skb, struct inet6_dev *idev, ...@@ -3090,8 +3090,7 @@ static int inet6_fill_ifinfo(struct sk_buff *skb, struct inet6_dev *idev,
nlmsg_failure: nlmsg_failure:
rtattr_failure: rtattr_failure:
if (array) kfree(array);
kfree(array);
skb_trim(skb, b - skb->data); skb_trim(skb, b - skb->data);
return -1; return -1;
} }
......
...@@ -587,8 +587,7 @@ static int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *)) ...@@ -587,8 +587,7 @@ static int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *))
skb->next = NULL; skb->next = NULL;
} }
if (tmp_hdr) kfree(tmp_hdr);
kfree(tmp_hdr);
if (err == 0) { if (err == 0) {
IP6_INC_STATS(IPSTATS_MIB_FRAGOKS); IP6_INC_STATS(IPSTATS_MIB_FRAGOKS);
...@@ -1186,10 +1185,8 @@ int ip6_push_pending_frames(struct sock *sk) ...@@ -1186,10 +1185,8 @@ int ip6_push_pending_frames(struct sock *sk)
out: out:
inet->cork.flags &= ~IPCORK_OPT; inet->cork.flags &= ~IPCORK_OPT;
if (np->cork.opt) { kfree(np->cork.opt);
kfree(np->cork.opt); np->cork.opt = NULL;
np->cork.opt = NULL;
}
if (np->cork.rt) { if (np->cork.rt) {
dst_release(&np->cork.rt->u.dst); dst_release(&np->cork.rt->u.dst);
np->cork.rt = NULL; np->cork.rt = NULL;
...@@ -1214,10 +1211,8 @@ void ip6_flush_pending_frames(struct sock *sk) ...@@ -1214,10 +1211,8 @@ void ip6_flush_pending_frames(struct sock *sk)
inet->cork.flags &= ~IPCORK_OPT; inet->cork.flags &= ~IPCORK_OPT;
if (np->cork.opt) { kfree(np->cork.opt);
kfree(np->cork.opt); np->cork.opt = NULL;
np->cork.opt = NULL;
}
if (np->cork.rt) { if (np->cork.rt) {
dst_release(&np->cork.rt->u.dst); dst_release(&np->cork.rt->u.dst);
np->cork.rt = NULL; np->cork.rt = NULL;
......
...@@ -756,8 +756,7 @@ ip6ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -756,8 +756,7 @@ ip6ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev)
} }
ip6_tnl_dst_store(t, dst); ip6_tnl_dst_store(t, dst);
if (opt) kfree(opt);
kfree(opt);
t->recursion--; t->recursion--;
return 0; return 0;
...@@ -766,8 +765,7 @@ ip6ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -766,8 +765,7 @@ ip6ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev)
dst_link_failure(skb); dst_link_failure(skb);
tx_err_dst_release: tx_err_dst_release:
dst_release(dst); dst_release(dst);
if (opt) kfree(opt);
kfree(opt);
tx_err: tx_err:
stats->tx_errors++; stats->tx_errors++;
stats->tx_dropped++; stats->tx_dropped++;
......
...@@ -130,8 +130,7 @@ static int ipcomp6_input(struct xfrm_state *x, struct xfrm_decap_state *decap, s ...@@ -130,8 +130,7 @@ static int ipcomp6_input(struct xfrm_state *x, struct xfrm_decap_state *decap, s
out_put_cpu: out_put_cpu:
put_cpu(); put_cpu();
out: out:
if (tmp_hdr) kfree(tmp_hdr);
kfree(tmp_hdr);
if (err) if (err)
goto error_out; goto error_out;
return nexthdr; return nexthdr;
......
...@@ -80,8 +80,7 @@ int ip6_ra_control(struct sock *sk, int sel, void (*destructor)(struct sock *)) ...@@ -80,8 +80,7 @@ int ip6_ra_control(struct sock *sk, int sel, void (*destructor)(struct sock *))
if (ra->sk == sk) { if (ra->sk == sk) {
if (sel>=0) { if (sel>=0) {
write_unlock_bh(&ip6_ra_lock); write_unlock_bh(&ip6_ra_lock);
if (new_ra) kfree(new_ra);
kfree(new_ra);
return -EADDRINUSE; return -EADDRINUSE;
} }
......
...@@ -194,8 +194,7 @@ void irlmp_expire_discoveries(hashbin_t *log, __u32 saddr, int force) ...@@ -194,8 +194,7 @@ void irlmp_expire_discoveries(hashbin_t *log, __u32 saddr, int force)
/* Remove it from the log */ /* Remove it from the log */
curr = hashbin_remove_this(log, (irda_queue_t *) curr); curr = hashbin_remove_this(log, (irda_queue_t *) curr);
if (curr) kfree(curr);
kfree(curr);
} }
} }
......
...@@ -122,8 +122,7 @@ static void __irias_delete_attrib(struct ias_attrib *attrib) ...@@ -122,8 +122,7 @@ static void __irias_delete_attrib(struct ias_attrib *attrib)
IRDA_ASSERT(attrib != NULL, return;); IRDA_ASSERT(attrib != NULL, return;);
IRDA_ASSERT(attrib->magic == IAS_ATTRIB_MAGIC, return;); IRDA_ASSERT(attrib->magic == IAS_ATTRIB_MAGIC, return;);
if (attrib->name) kfree(attrib->name);
kfree(attrib->name);
irias_delete_value(attrib->value); irias_delete_value(attrib->value);
attrib->magic = ~IAS_ATTRIB_MAGIC; attrib->magic = ~IAS_ATTRIB_MAGIC;
...@@ -136,8 +135,7 @@ void __irias_delete_object(struct ias_object *obj) ...@@ -136,8 +135,7 @@ void __irias_delete_object(struct ias_object *obj)
IRDA_ASSERT(obj != NULL, return;); IRDA_ASSERT(obj != NULL, return;);
IRDA_ASSERT(obj->magic == IAS_OBJECT_MAGIC, return;); IRDA_ASSERT(obj->magic == IAS_OBJECT_MAGIC, return;);
if (obj->name) kfree(obj->name);
kfree(obj->name);
hashbin_delete(obj->attribs, (FREE_FUNC) __irias_delete_attrib); hashbin_delete(obj->attribs, (FREE_FUNC) __irias_delete_attrib);
...@@ -562,14 +560,12 @@ void irias_delete_value(struct ias_value *value) ...@@ -562,14 +560,12 @@ void irias_delete_value(struct ias_value *value)
/* No need to deallocate */ /* No need to deallocate */
break; break;
case IAS_STRING: case IAS_STRING:
/* If string, deallocate string */ /* Deallocate string */
if (value->t.string != NULL) kfree(value->t.string);
kfree(value->t.string);
break; break;
case IAS_OCT_SEQ: case IAS_OCT_SEQ:
/* If byte stream, deallocate byte stream */ /* Deallocate byte stream */
if (value->t.oct_seq != NULL) kfree(value->t.oct_seq);
kfree(value->t.oct_seq);
break; break;
default: default:
IRDA_DEBUG(0, "%s(), Unknown value type!\n", __FUNCTION__); IRDA_DEBUG(0, "%s(), Unknown value type!\n", __FUNCTION__);
......
...@@ -240,8 +240,7 @@ static void rose_remove_neigh(struct rose_neigh *rose_neigh) ...@@ -240,8 +240,7 @@ static void rose_remove_neigh(struct rose_neigh *rose_neigh)
if ((s = rose_neigh_list) == rose_neigh) { if ((s = rose_neigh_list) == rose_neigh) {
rose_neigh_list = rose_neigh->next; rose_neigh_list = rose_neigh->next;
spin_unlock_bh(&rose_neigh_list_lock); spin_unlock_bh(&rose_neigh_list_lock);
if (rose_neigh->digipeat != NULL) kfree(rose_neigh->digipeat);
kfree(rose_neigh->digipeat);
kfree(rose_neigh); kfree(rose_neigh);
return; return;
} }
...@@ -250,8 +249,7 @@ static void rose_remove_neigh(struct rose_neigh *rose_neigh) ...@@ -250,8 +249,7 @@ static void rose_remove_neigh(struct rose_neigh *rose_neigh)
if (s->next == rose_neigh) { if (s->next == rose_neigh) {
s->next = rose_neigh->next; s->next = rose_neigh->next;
spin_unlock_bh(&rose_neigh_list_lock); spin_unlock_bh(&rose_neigh_list_lock);
if (rose_neigh->digipeat != NULL) kfree(rose_neigh->digipeat);
kfree(rose_neigh->digipeat);
kfree(rose_neigh); kfree(rose_neigh);
return; return;
} }
......
...@@ -298,8 +298,7 @@ static int fw_change(struct tcf_proto *tp, unsigned long base, ...@@ -298,8 +298,7 @@ static int fw_change(struct tcf_proto *tp, unsigned long base,
return 0; return 0;
errout: errout:
if (f) kfree(f);
kfree(f);
return err; return err;
} }
......
...@@ -525,8 +525,7 @@ static int route4_change(struct tcf_proto *tp, unsigned long base, ...@@ -525,8 +525,7 @@ static int route4_change(struct tcf_proto *tp, unsigned long base,
return 0; return 0;
errout: errout:
if (f) kfree(f);
kfree(f);
return err; return err;
} }
......
...@@ -555,8 +555,7 @@ static int rsvp_change(struct tcf_proto *tp, unsigned long base, ...@@ -555,8 +555,7 @@ static int rsvp_change(struct tcf_proto *tp, unsigned long base,
goto insert; goto insert;
errout: errout:
if (f) kfree(f);
kfree(f);
errout2: errout2:
tcf_exts_destroy(tp, &e); tcf_exts_destroy(tp, &e);
return err; return err;
......
...@@ -194,8 +194,7 @@ __tcindex_delete(struct tcf_proto *tp, unsigned long arg, int lock) ...@@ -194,8 +194,7 @@ __tcindex_delete(struct tcf_proto *tp, unsigned long arg, int lock)
} }
tcf_unbind_filter(tp, &r->res); tcf_unbind_filter(tp, &r->res);
tcf_exts_destroy(tp, &r->exts); tcf_exts_destroy(tp, &r->exts);
if (f) kfree(f);
kfree(f);
return 0; return 0;
} }
...@@ -442,10 +441,8 @@ static void tcindex_destroy(struct tcf_proto *tp) ...@@ -442,10 +441,8 @@ static void tcindex_destroy(struct tcf_proto *tp)
walker.skip = 0; walker.skip = 0;
walker.fn = &tcindex_destroy_element; walker.fn = &tcindex_destroy_element;
tcindex_walk(tp,&walker); tcindex_walk(tp,&walker);
if (p->perfect) kfree(p->perfect);
kfree(p->perfect); kfree(p->h);
if (p->h)
kfree(p->h);
kfree(p); kfree(p);
tp->root = NULL; tp->root = NULL;
} }
......
...@@ -347,7 +347,7 @@ static int u32_destroy_key(struct tcf_proto *tp, struct tc_u_knode *n) ...@@ -347,7 +347,7 @@ static int u32_destroy_key(struct tcf_proto *tp, struct tc_u_knode *n)
if (n->ht_down) if (n->ht_down)
n->ht_down->refcnt--; n->ht_down->refcnt--;
#ifdef CONFIG_CLS_U32_PERF #ifdef CONFIG_CLS_U32_PERF
if (n && (NULL != n->pf)) if (n)
kfree(n->pf); kfree(n->pf);
#endif #endif
kfree(n); kfree(n);
...@@ -680,7 +680,7 @@ static int u32_change(struct tcf_proto *tp, unsigned long base, u32 handle, ...@@ -680,7 +680,7 @@ static int u32_change(struct tcf_proto *tp, unsigned long base, u32 handle,
return 0; return 0;
} }
#ifdef CONFIG_CLS_U32_PERF #ifdef CONFIG_CLS_U32_PERF
if (n && (NULL != n->pf)) if (n)
kfree(n->pf); kfree(n->pf);
#endif #endif
kfree(n); kfree(n);
......
...@@ -561,8 +561,7 @@ static int meta_var_change(struct meta_value *dst, struct rtattr *rta) ...@@ -561,8 +561,7 @@ static int meta_var_change(struct meta_value *dst, struct rtattr *rta)
static void meta_var_destroy(struct meta_value *v) static void meta_var_destroy(struct meta_value *v)
{ {
if (v->val) kfree((void *) v->val);
kfree((void *) v->val);
} }
static void meta_var_apply_extras(struct meta_value *v, static void meta_var_apply_extras(struct meta_value *v,
......
...@@ -344,9 +344,7 @@ void sctp_association_free(struct sctp_association *asoc) ...@@ -344,9 +344,7 @@ void sctp_association_free(struct sctp_association *asoc)
} }
/* Free peer's cached cookie. */ /* Free peer's cached cookie. */
if (asoc->peer.cookie) { kfree(asoc->peer.cookie);
kfree(asoc->peer.cookie);
}
/* Release the transport structures. */ /* Release the transport structures. */
list_for_each_safe(pos, temp, &asoc->peer.transport_addr_list) { list_for_each_safe(pos, temp, &asoc->peer.transport_addr_list) {
......
...@@ -254,8 +254,7 @@ struct sctp_chunk *sctp_make_init(const struct sctp_association *asoc, ...@@ -254,8 +254,7 @@ struct sctp_chunk *sctp_make_init(const struct sctp_association *asoc,
aiparam.adaption_ind = htonl(sp->adaption_ind); aiparam.adaption_ind = htonl(sp->adaption_ind);
sctp_addto_chunk(retval, sizeof(aiparam), &aiparam); sctp_addto_chunk(retval, sizeof(aiparam), &aiparam);
nodata: nodata:
if (addrs.v) kfree(addrs.v);
kfree(addrs.v);
return retval; return retval;
} }
...@@ -347,8 +346,7 @@ struct sctp_chunk *sctp_make_init_ack(const struct sctp_association *asoc, ...@@ -347,8 +346,7 @@ struct sctp_chunk *sctp_make_init_ack(const struct sctp_association *asoc,
nomem_chunk: nomem_chunk:
kfree(cookie); kfree(cookie);
nomem_cookie: nomem_cookie:
if (addrs.v) kfree(addrs.v);
kfree(addrs.v);
return retval; return retval;
} }
......
...@@ -143,6 +143,6 @@ gss_get_mic_kerberos(struct gss_ctx *gss_ctx, struct xdr_buf *text, ...@@ -143,6 +143,6 @@ gss_get_mic_kerberos(struct gss_ctx *gss_ctx, struct xdr_buf *text,
return ((ctx->endtime < now) ? GSS_S_CONTEXT_EXPIRED : GSS_S_COMPLETE); return ((ctx->endtime < now) ? GSS_S_CONTEXT_EXPIRED : GSS_S_COMPLETE);
out_err: out_err:
if (md5cksum.data) kfree(md5cksum.data); kfree(md5cksum.data);
return GSS_S_FAILURE; return GSS_S_FAILURE;
} }
...@@ -176,6 +176,6 @@ gss_verify_mic_kerberos(struct gss_ctx *gss_ctx, ...@@ -176,6 +176,6 @@ gss_verify_mic_kerberos(struct gss_ctx *gss_ctx,
ret = GSS_S_COMPLETE; ret = GSS_S_COMPLETE;
out: out:
if (md5cksum.data) kfree(md5cksum.data); kfree(md5cksum.data);
return ret; return ret;
} }
...@@ -60,8 +60,7 @@ gss_mech_free(struct gss_api_mech *gm) ...@@ -60,8 +60,7 @@ gss_mech_free(struct gss_api_mech *gm)
for (i = 0; i < gm->gm_pf_num; i++) { for (i = 0; i < gm->gm_pf_num; i++) {
pf = &gm->gm_pfs[i]; pf = &gm->gm_pfs[i];
if (pf->auth_domain_name) kfree(pf->auth_domain_name);
kfree(pf->auth_domain_name);
pf->auth_domain_name = NULL; pf->auth_domain_name = NULL;
} }
} }
......
...@@ -122,8 +122,7 @@ spkm3_make_token(struct spkm3_ctx *ctx, ...@@ -122,8 +122,7 @@ spkm3_make_token(struct spkm3_ctx *ctx,
return GSS_S_COMPLETE; return GSS_S_COMPLETE;
out_err: out_err:
if (md5cksum.data) kfree(md5cksum.data);
kfree(md5cksum.data);
token->data = NULL; token->data = NULL;
token->len = 0; token->len = 0;
return GSS_S_FAILURE; return GSS_S_FAILURE;
......
...@@ -259,8 +259,7 @@ spkm3_verify_mic_token(unsigned char **tokp, int *mic_hdrlen, unsigned char **ck ...@@ -259,8 +259,7 @@ spkm3_verify_mic_token(unsigned char **tokp, int *mic_hdrlen, unsigned char **ck
ret = GSS_S_COMPLETE; ret = GSS_S_COMPLETE;
out: out:
if (spkm3_ctx_id.data) kfree(spkm3_ctx_id.data);
kfree(spkm3_ctx_id.data);
return ret; return ret;
} }
...@@ -120,9 +120,7 @@ spkm3_read_token(struct spkm3_ctx *ctx, ...@@ -120,9 +120,7 @@ spkm3_read_token(struct spkm3_ctx *ctx,
/* XXX: need to add expiration and sequencing */ /* XXX: need to add expiration and sequencing */
ret = GSS_S_COMPLETE; ret = GSS_S_COMPLETE;
out: out:
if (md5cksum.data) kfree(md5cksum.data);
kfree(md5cksum.data); kfree(wire_cksum.data);
if (wire_cksum.data)
kfree(wire_cksum.data);
return ret; return ret;
} }
...@@ -196,12 +196,9 @@ svc_exit_thread(struct svc_rqst *rqstp) ...@@ -196,12 +196,9 @@ svc_exit_thread(struct svc_rqst *rqstp)
struct svc_serv *serv = rqstp->rq_server; struct svc_serv *serv = rqstp->rq_server;
svc_release_buffer(rqstp); svc_release_buffer(rqstp);
if (rqstp->rq_resp) kfree(rqstp->rq_resp);
kfree(rqstp->rq_resp); kfree(rqstp->rq_argp);
if (rqstp->rq_argp) kfree(rqstp->rq_auth_data);
kfree(rqstp->rq_argp);
if (rqstp->rq_auth_data)
kfree(rqstp->rq_auth_data);
kfree(rqstp); kfree(rqstp);
/* Release the server */ /* Release the server */
......
...@@ -992,8 +992,7 @@ xdr_xcode_array2(struct xdr_buf *buf, unsigned int base, ...@@ -992,8 +992,7 @@ xdr_xcode_array2(struct xdr_buf *buf, unsigned int base,
err = 0; err = 0;
out: out:
if (elem) kfree(elem);
kfree(elem);
if (ppages) if (ppages)
kunmap(*ppages); kunmap(*ppages);
return err; return err;
......
...@@ -1099,7 +1099,7 @@ static void release_driver(struct sock *sk) ...@@ -1099,7 +1099,7 @@ static void release_driver(struct sock *sk)
sock_reset_flag(sk, SOCK_ZAPPED); sock_reset_flag(sk, SOCK_ZAPPED);
wp = wp_sk(sk); wp = wp_sk(sk);
if (wp && wp->mbox) { if (wp) {
kfree(wp->mbox); kfree(wp->mbox);
wp->mbox = NULL; wp->mbox = NULL;
} }
...@@ -1186,10 +1186,8 @@ static void wanpipe_kill_sock_timer (unsigned long data) ...@@ -1186,10 +1186,8 @@ static void wanpipe_kill_sock_timer (unsigned long data)
return; return;
} }
if (wp_sk(sk)) { kfree(wp_sk(sk));
kfree(wp_sk(sk)); wp_sk(sk) = NULL;
wp_sk(sk) = NULL;
}
if (atomic_read(&sk->sk_refcnt) != 1) { if (atomic_read(&sk->sk_refcnt) != 1) {
atomic_set(&sk->sk_refcnt, 1); atomic_set(&sk->sk_refcnt, 1);
...@@ -1219,10 +1217,8 @@ static void wanpipe_kill_sock_accept (struct sock *sk) ...@@ -1219,10 +1217,8 @@ static void wanpipe_kill_sock_accept (struct sock *sk)
sk->sk_socket = NULL; sk->sk_socket = NULL;
if (wp_sk(sk)) { kfree(wp_sk(sk));
kfree(wp_sk(sk)); wp_sk(sk) = NULL;
wp_sk(sk) = NULL;
}
if (atomic_read(&sk->sk_refcnt) != 1) { if (atomic_read(&sk->sk_refcnt) != 1) {
atomic_set(&sk->sk_refcnt, 1); atomic_set(&sk->sk_refcnt, 1);
...@@ -1243,10 +1239,8 @@ static void wanpipe_kill_sock_irq (struct sock *sk) ...@@ -1243,10 +1239,8 @@ static void wanpipe_kill_sock_irq (struct sock *sk)
sk->sk_socket = NULL; sk->sk_socket = NULL;
if (wp_sk(sk)) { kfree(wp_sk(sk));
kfree(wp_sk(sk)); wp_sk(sk) = NULL;
wp_sk(sk) = NULL;
}
if (atomic_read(&sk->sk_refcnt) != 1) { if (atomic_read(&sk->sk_refcnt) != 1) {
atomic_set(&sk->sk_refcnt, 1); atomic_set(&sk->sk_refcnt, 1);
......
...@@ -714,10 +714,8 @@ static int wanrouter_device_new_if(struct wan_device *wandev, ...@@ -714,10 +714,8 @@ static int wanrouter_device_new_if(struct wan_device *wandev,
} }
/* This code has moved from del_if() function */ /* This code has moved from del_if() function */
if (dev->priv) { kfree(dev->priv);
kfree(dev->priv); dev->priv = NULL;
dev->priv = NULL;
}
#ifdef CONFIG_WANPIPE_MULTPPP #ifdef CONFIG_WANPIPE_MULTPPP
if (cnf->config_id == WANCONFIG_MPPP) if (cnf->config_id == WANCONFIG_MPPP)
...@@ -851,10 +849,8 @@ static int wanrouter_delete_interface(struct wan_device *wandev, char *name) ...@@ -851,10 +849,8 @@ static int wanrouter_delete_interface(struct wan_device *wandev, char *name)
/* Due to new interface linking method using dev->priv, /* Due to new interface linking method using dev->priv,
* this code has moved from del_if() function.*/ * this code has moved from del_if() function.*/
if (dev->priv){ kfree(dev->priv);
kfree(dev->priv); dev->priv=NULL;
dev->priv=NULL;
}
unregister_netdev(dev); unregister_netdev(dev);
......
...@@ -62,14 +62,10 @@ static void xfrm_state_gc_destroy(struct xfrm_state *x) ...@@ -62,14 +62,10 @@ static void xfrm_state_gc_destroy(struct xfrm_state *x)
{ {
if (del_timer(&x->timer)) if (del_timer(&x->timer))
BUG(); BUG();
if (x->aalg) kfree(x->aalg);
kfree(x->aalg); kfree(x->ealg);
if (x->ealg) kfree(x->calg);
kfree(x->ealg); kfree(x->encap);
if (x->calg)
kfree(x->calg);
if (x->encap)
kfree(x->encap);
if (x->type) { if (x->type) {
x->type->destructor(x); x->type->destructor(x);
xfrm_put_type(x->type); xfrm_put_type(x->type);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment