diff options
author | Jesper Juhl <juhl-lkml@dif.dk> | 2005-05-03 17:33:27 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2005-05-03 17:33:27 -0400 |
commit | 6a5d362120a61a719095443194cc2d5e9a7027dd (patch) | |
tree | 7cab13ff0d252b96f4eeda7475f805ffdd1c0c4a /drivers/net/wan/x25_asy.c | |
parent | db46edc6d3b66bf708a8f23a9aa89f63a49ebe33 (diff) |
[WAN]: kfree of NULL pointer is valid
kfree(0) is perfectly valid, checking pointers for NULL before calling
kfree() on them is redundant. The patch below cleans away a few such
redundant checks (and while I was around some of those bits I couldn't
stop myself from making a few tiny whitespace changes as well).
Signed-off-by: Jesper Juhl <juhl-lkml@dif.dk>
Acked-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/wan/x25_asy.c')
-rw-r--r-- | drivers/net/wan/x25_asy.c | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/drivers/net/wan/x25_asy.c b/drivers/net/wan/x25_asy.c index 8c5cfcb55826..1c540d825551 100644 --- a/drivers/net/wan/x25_asy.c +++ b/drivers/net/wan/x25_asy.c | |||
@@ -107,13 +107,9 @@ static struct x25_asy *x25_asy_alloc(void) | |||
107 | static void x25_asy_free(struct x25_asy *sl) | 107 | static void x25_asy_free(struct x25_asy *sl) |
108 | { | 108 | { |
109 | /* Free all X.25 frame buffers. */ | 109 | /* Free all X.25 frame buffers. */ |
110 | if (sl->rbuff) { | 110 | kfree(sl->rbuff); |
111 | kfree(sl->rbuff); | ||
112 | } | ||
113 | sl->rbuff = NULL; | 111 | sl->rbuff = NULL; |
114 | if (sl->xbuff) { | 112 | kfree(sl->xbuff); |
115 | kfree(sl->xbuff); | ||
116 | } | ||
117 | sl->xbuff = NULL; | 113 | sl->xbuff = NULL; |
118 | 114 | ||
119 | if (!test_and_clear_bit(SLF_INUSE, &sl->flags)) { | 115 | if (!test_and_clear_bit(SLF_INUSE, &sl->flags)) { |
@@ -134,10 +130,8 @@ static int x25_asy_change_mtu(struct net_device *dev, int newmtu) | |||
134 | { | 130 | { |
135 | printk("%s: unable to grow X.25 buffers, MTU change cancelled.\n", | 131 | printk("%s: unable to grow X.25 buffers, MTU change cancelled.\n", |
136 | dev->name); | 132 | dev->name); |
137 | if (xbuff != NULL) | 133 | kfree(xbuff); |
138 | kfree(xbuff); | 134 | kfree(rbuff); |
139 | if (rbuff != NULL) | ||
140 | kfree(rbuff); | ||
141 | return -ENOMEM; | 135 | return -ENOMEM; |
142 | } | 136 | } |
143 | 137 | ||
@@ -169,10 +163,8 @@ static int x25_asy_change_mtu(struct net_device *dev, int newmtu) | |||
169 | 163 | ||
170 | spin_unlock_bh(&sl->lock); | 164 | spin_unlock_bh(&sl->lock); |
171 | 165 | ||
172 | if (xbuff != NULL) | 166 | kfree(xbuff); |
173 | kfree(xbuff); | 167 | kfree(rbuff); |
174 | if (rbuff != NULL) | ||
175 | kfree(rbuff); | ||
176 | return 0; | 168 | return 0; |
177 | } | 169 | } |
178 | 170 | ||