]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
staging: rts5208: Remove NULL test before vfree
authorBhaktipriya Shridhar <bhaktipriya96@gmail.com>
Sun, 28 Feb 2016 20:28:44 +0000 (01:58 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 12 Mar 2016 06:09:09 +0000 (22:09 -0800)
vfree frees the virtually continuous memory area starting at addr.
If addr is NULL, no operation is performed. So NULL test is not needed
before vfree.

This was done using Coccinelle:

@@
expression x;
@@
-if (x != NULL)
    vfree(x);

@@
expression x;
@@

-if (x != NULL) {
vfree(x);
x = NULL;
-}

Signed-off-by: Bhaktipriya Shridhar <bhaktipriya96@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rts5208/ms.c
drivers/staging/rts5208/xd.c

index b8c9337b514f8632e2dd189954ccbf1443485282..643301589bded589d09a4cfc03d86af102e6892c 100644 (file)
@@ -2457,10 +2457,8 @@ static int ms_init_l2p_tbl(struct rtsx_chip *chip)
        return STATUS_SUCCESS;
 
 INIT_FAIL:
-       if (ms_card->segment) {
-               vfree(ms_card->segment);
-               ms_card->segment = NULL;
-       }
+       vfree(ms_card->segment);
+       ms_card->segment = NULL;
 
        return STATUS_FAIL;
 }
@@ -2803,14 +2801,10 @@ static int ms_build_l2p_tbl(struct rtsx_chip *chip, int seg_no)
 
 BUILD_FAIL:
        segment->build_flag = 0;
-       if (segment->l2p_table) {
-               vfree(segment->l2p_table);
-               segment->l2p_table = NULL;
-       }
-       if (segment->free_table) {
-               vfree(segment->free_table);
-               segment->free_table = NULL;
-       }
+       vfree(segment->l2p_table);
+       segment->l2p_table = NULL;
+       vfree(segment->free_table);
+       segment->free_table = NULL;
 
        return STATUS_FAIL;
 }
@@ -4096,14 +4090,10 @@ void ms_free_l2p_tbl(struct rtsx_chip *chip)
 
        if (ms_card->segment != NULL) {
                for (i = 0; i < ms_card->segment_cnt; i++) {
-                       if (ms_card->segment[i].l2p_table != NULL) {
-                               vfree(ms_card->segment[i].l2p_table);
-                               ms_card->segment[i].l2p_table = NULL;
-                       }
-                       if (ms_card->segment[i].free_table != NULL) {
-                               vfree(ms_card->segment[i].free_table);
-                               ms_card->segment[i].free_table = NULL;
-                       }
+                       vfree(ms_card->segment[i].l2p_table);
+                       ms_card->segment[i].l2p_table = NULL;
+                       vfree(ms_card->segment[i].free_table);
+                       ms_card->segment[i].free_table = NULL;
                }
                vfree(ms_card->segment);
                ms_card->segment = NULL;
index fe84f757d5759800b109a9ffff2f532f316e87b4..fc1dfe0991d424a5cbcc8900eb8c0f3a9ecb936b 100644 (file)
@@ -903,14 +903,10 @@ static inline void free_zone(struct zone_entry *zone)
        zone->set_index = 0;
        zone->get_index = 0;
        zone->unused_blk_cnt = 0;
-       if (zone->l2p_table) {
-               vfree(zone->l2p_table);
-               zone->l2p_table = NULL;
-       }
-       if (zone->free_table) {
-               vfree(zone->free_table);
-               zone->free_table = NULL;
-       }
+       vfree(zone->l2p_table);
+       zone->l2p_table = NULL;
+       vfree(zone->free_table);
+       zone->free_table = NULL;
 }
 
 static void xd_set_unused_block(struct rtsx_chip *chip, u32 phy_blk)
@@ -1588,14 +1584,10 @@ static int xd_build_l2p_tbl(struct rtsx_chip *chip, int zone_no)
        return STATUS_SUCCESS;
 
 Build_Fail:
-       if (zone->l2p_table) {
-               vfree(zone->l2p_table);
-               zone->l2p_table = NULL;
-       }
-       if (zone->free_table) {
-               vfree(zone->free_table);
-               zone->free_table = NULL;
-       }
+       vfree(zone->l2p_table);
+       zone->l2p_table = NULL;
+       vfree(zone->free_table);
+       zone->free_table = NULL;
 
        return STATUS_FAIL;
 }
@@ -2251,14 +2243,10 @@ void xd_free_l2p_tbl(struct rtsx_chip *chip)
 
        if (xd_card->zone != NULL) {
                for (i = 0; i < xd_card->zone_cnt; i++) {
-                       if (xd_card->zone[i].l2p_table != NULL) {
-                               vfree(xd_card->zone[i].l2p_table);
-                               xd_card->zone[i].l2p_table = NULL;
-                       }
-                       if (xd_card->zone[i].free_table != NULL) {
-                               vfree(xd_card->zone[i].free_table);
-                               xd_card->zone[i].free_table = NULL;
-                       }
+                       vfree(xd_card->zone[i].l2p_table);
+                       xd_card->zone[i].l2p_table = NULL;
+                       vfree(xd_card->zone[i].free_table);
+                       xd_card->zone[i].free_table = NULL;
                }
                vfree(xd_card->zone);
                xd_card->zone = NULL;