[PATCH] Remove redundant NULL checks before [kv]free - in drivers/
authorJesper Juhl <jesper.juhl@gmail.com>
Tue, 27 Jun 2006 09:55:06 +0000 (02:55 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Wed, 28 Jun 2006 00:32:48 +0000 (17:32 -0700)
Remove redundant NULL chck before kfree + tiny CodingStyle cleanup for
drivers/

Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
drivers/char/agp/sgi-agp.c
drivers/char/hvcs.c
drivers/message/fusion/mptfc.c
drivers/message/fusion/mptsas.c
drivers/net/fs_enet/fs_enet-mii.c
drivers/net/wireless/ipw2200.c
drivers/scsi/libata-scsi.c
drivers/video/au1100fb.c

index cfa7922cb431f500788b6d0ba6360312137eee03..d73be4c2db8a9c5c6fffe250d36e2e3593ac53f5 100644 (file)
@@ -329,9 +329,8 @@ static int __devinit agp_sgi_init(void)
 
 static void __devexit agp_sgi_cleanup(void)
 {
-       if (sgi_tioca_agp_bridges)
-               kfree(sgi_tioca_agp_bridges);
-       sgi_tioca_agp_bridges=NULL;
+       kfree(sgi_tioca_agp_bridges);
+       sgi_tioca_agp_bridges = NULL;
 }
 
 module_init(agp_sgi_init);
index 8d97b3911293bf46436bd743ae9c28aaad714316..afa26b65dac3b7fb4313df3e1b6e003951bf2d9d 100644 (file)
@@ -1320,11 +1320,12 @@ static struct tty_operations hvcs_ops = {
 static int hvcs_alloc_index_list(int n)
 {
        int i;
+
        hvcs_index_list = kmalloc(n * sizeof(hvcs_index_count),GFP_KERNEL);
        if (!hvcs_index_list)
                return -ENOMEM;
        hvcs_index_count = n;
-       for(i = 0; i < hvcs_index_count; i++)
+       for (i = 0; i < hvcs_index_count; i++)
                hvcs_index_list[i] = -1;
        return 0;
 }
@@ -1332,11 +1333,9 @@ static int hvcs_alloc_index_list(int n)
 static void hvcs_free_index_list(void)
 {
        /* Paranoia check to be thorough. */
-       if (hvcs_index_list) {
-               kfree(hvcs_index_list);
-               hvcs_index_list = NULL;
-               hvcs_index_count = 0;
-       }
+       kfree(hvcs_index_list);
+       hvcs_index_list = NULL;
+       hvcs_index_count = 0;
 }
 
 static int __init hvcs_module_init(void)
index 74714e5bcf03299cc960529ab25c66ef3a061d0b..3ff8378ea660ad9aad1330122efd408f5faade01 100644 (file)
@@ -305,10 +305,8 @@ mptfc_GetFcDevPage0(MPT_ADAPTER *ioc, int ioc_port,
        }
 
  out:
-       if (pp0_array)
-               kfree(pp0_array);
-       if (p0_array)
-               kfree(p0_array);
+       kfree(pp0_array);
+       kfree(p0_array);
        return rc;
 }
 
index af6ec553ff7ca54c3cf4ee14c7e43e32cd9e73a2..85689ab46cbc26fcc30db0e471cc5081abd5dc66 100644 (file)
@@ -1378,8 +1378,7 @@ mptsas_probe_hba_phys(MPT_ADAPTER *ioc)
        return 0;
 
  out_free_port_info:
-       if (hba)
-               kfree(hba);
+       kfree(hba);
  out:
        return error;
 }
index c6770377ef8746c384d815d5067a469d872a3b59..0cd07150bf4aeee6e3add86d7e6e5e23544c3288 100644 (file)
@@ -431,8 +431,7 @@ static struct fs_enet_mii_bus *create_bus(const struct fs_mii_bus_info *bi)
        return bus;
 
 err:
-       if (bus)
-               kfree(bus);
+       kfree(bus);
        return ERR_PTR(ret);
 }
 
index 081a8999666e7e168404141073c687d0af2dfe0b..a8a8f975432fe1e32a3fb04aa0a4bc2d59d94e24 100644 (file)
@@ -1229,12 +1229,6 @@ static struct ipw_fw_error *ipw_alloc_error_log(struct ipw_priv *priv)
        return error;
 }
 
-static void ipw_free_error_log(struct ipw_fw_error *error)
-{
-       if (error)
-               kfree(error);
-}
-
 static ssize_t show_event_log(struct device *d,
                              struct device_attribute *attr, char *buf)
 {
@@ -1296,10 +1290,9 @@ static ssize_t clear_error(struct device *d,
                           const char *buf, size_t count)
 {
        struct ipw_priv *priv = dev_get_drvdata(d);
-       if (priv->error) {
-               ipw_free_error_log(priv->error);
-               priv->error = NULL;
-       }
+
+       kfree(priv->error);
+       priv->error = NULL;
        return count;
 }
 
@@ -1970,8 +1963,7 @@ static void ipw_irq_tasklet(struct ipw_priv *priv)
                                struct ipw_fw_error *error =
                                    ipw_alloc_error_log(priv);
                                ipw_dump_error_log(priv, error);
-                               if (error)
-                                       ipw_free_error_log(error);
+                               kfree(error);
                        }
 #endif
                } else {
@@ -11693,10 +11685,8 @@ static void ipw_pci_remove(struct pci_dev *pdev)
                }
        }
 
-       if (priv->error) {
-               ipw_free_error_log(priv->error);
-               priv->error = NULL;
-       }
+       kfree(priv->error);
+       priv->error = NULL;
 
 #ifdef CONFIG_IPW2200_PROMISCUOUS
        ipw_prom_free(priv);
index 93d18a74c401c37fe194422377736718c8bb02b1..2915bca691e8e941bd3813ab63b7de41532ef564 100644 (file)
@@ -222,9 +222,7 @@ int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg)
         && copy_to_user(arg + sizeof(args), argbuf, argsize))
                rc = -EFAULT;
 error:
-       if (argbuf)
-               kfree(argbuf);
-
+       kfree(argbuf);
        return rc;
 }
 
index d63c3f485853e52eb9b351bd7991295c05df1ebe..9ef68cd83bb4d0cc527524c073779fae21579d20 100644 (file)
@@ -743,8 +743,7 @@ void __exit au1100fb_cleanup(void)
 {
        driver_unregister(&au1100fb_driver);
 
-       if (drv_info.opt_mode)
-               kfree(drv_info.opt_mode);
+       kfree(drv_info.opt_mode);
 }
 
 module_init(au1100fb_init);