[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>
This commit is contained in:
Jesper Juhl
2005-05-03 14:33:27 -07:00
committed by David S. Miller
父節點 db46edc6d3
當前提交 6a5d362120
共有 4 個文件被更改,包括 23 次插入45 次删除

查看文件

@@ -107,13 +107,9 @@ static struct x25_asy *x25_asy_alloc(void)
static void x25_asy_free(struct x25_asy *sl)
{
/* Free all X.25 frame buffers. */
if (sl->rbuff) {
kfree(sl->rbuff);
}
kfree(sl->rbuff);
sl->rbuff = NULL;
if (sl->xbuff) {
kfree(sl->xbuff);
}
kfree(sl->xbuff);
sl->xbuff = NULL;
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)
{
printk("%s: unable to grow X.25 buffers, MTU change cancelled.\n",
dev->name);
if (xbuff != NULL)
kfree(xbuff);
if (rbuff != NULL)
kfree(rbuff);
kfree(xbuff);
kfree(rbuff);
return -ENOMEM;
}
@@ -169,10 +163,8 @@ static int x25_asy_change_mtu(struct net_device *dev, int newmtu)
spin_unlock_bh(&sl->lock);
if (xbuff != NULL)
kfree(xbuff);
if (rbuff != NULL)
kfree(rbuff);
kfree(xbuff);
kfree(rbuff);
return 0;
}