Skip to content

Commit

Permalink
[PATCH] Remove redundant NULL checks before [kv]free - in drivers/
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jesper Juhl authored and Linus Torvalds committed Jun 28, 2006
1 parent 9a66a53 commit 8f76078
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 38 deletions.
5 changes: 2 additions & 3 deletions drivers/char/agp/sgi-agp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
11 changes: 5 additions & 6 deletions drivers/char/hvcs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1320,23 +1320,22 @@ 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;
}

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)
Expand Down
6 changes: 2 additions & 4 deletions drivers/message/fusion/mptfc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
3 changes: 1 addition & 2 deletions drivers/message/fusion/mptsas.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
3 changes: 1 addition & 2 deletions drivers/net/fs_enet/fs_enet-mii.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
22 changes: 6 additions & 16 deletions drivers/net/wireless/ipw2200.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 1 addition & 3 deletions drivers/scsi/libata-scsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
3 changes: 1 addition & 2 deletions drivers/video/au1100fb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 8f76078

Please sign in to comment.