[PATCH] rapidio: fix ifnullfree.cocci warnings

From: kbuild test robot
Date: Mon Mar 21 2016 - 09:20:10 EST


drivers/rapidio/rio_cm.c:1401:4-9: WARNING: NULL check before freeing functions like kfree, debugfs_remove, debugfs_remove_recursive or usb_free_urb is not needed. Maybe consider reorganizing relevant code to avoid passing NULL values.
drivers/rapidio/rio_cm.c:1408:4-9: WARNING: NULL check before freeing functions like kfree, debugfs_remove, debugfs_remove_recursive or usb_free_urb is not needed. Maybe consider reorganizing relevant code to avoid passing NULL values.

NULL check before some freeing functions is not needed.

Based on checkpatch warning
"kfree(NULL) is safe this check is probably not required"
and kfreeaddr.cocci by Julia Lawall.

Generated by: scripts/coccinelle/free/ifnullfree.cocci

CC: Alexandre Bounine <alexandre.bounine@xxxxxxx>
Signed-off-by: Fengguang Wu <fengguang.wu@xxxxxxxxx>
---

rio_cm.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

--- a/drivers/rapidio/rio_cm.c
+++ b/drivers/rapidio/rio_cm.c
@@ -1397,15 +1397,15 @@ static void riocm_ch_free(struct kref *r

if (ch->rx_ring.inuse_cnt) {
for (i = 0; i < RIOCM_RX_RING_SIZE; i++) {
- if (ch->rx_ring.inuse[i] != NULL)
- kfree(ch->rx_ring.inuse[i]);
+ kfree(ch->rx_ring.inuse[i]);
}
}

if (ch->rx_ring.count)
for (i = 0; i < RIOCM_RX_RING_SIZE; i++)
- if (ch->rx_ring.buf[i] != NULL)
- kfree(ch->rx_ring.buf[i]);
+ {
+ kfree(ch->rx_ring.buf[i]);
+ }

complete(&ch->comp_close);
}