Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[PATCH] kfree cleanup: misc remaining drivers

This is the remaining misc drivers/ part of the big kfree cleanup patch.

Remove pointless checks for NULL prior to calling kfree() in misc files in
drivers/.

Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
Acked-by: Aristeu Sergio Rozanski Filho <aris@cathedrallabs.org>
Acked-by: Roland Dreier <rolandd@cisco.com>
Acked-by: Pierre Ossman <drzeus@drzeus.cx>
Acked-by: Jean Delvare <khali@linux-fr.org>
Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
Acked-by: Len Brown <len.brown@intel.com>
Acked-by: "Antonino A. Daplas" <adaplas@gmail.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by

Jesper Juhl and committed by
Linus Torvalds
6044ec88 2ea75330

+83 -151
+2 -4
drivers/acpi/container.c
··· 118 118 { 119 119 acpi_status status = AE_OK; 120 120 struct acpi_container *pc = NULL; 121 + 121 122 pc = (struct acpi_container *)acpi_driver_data(device); 122 - 123 - if (pc) 124 - kfree(pc); 125 - 123 + kfree(pc); 126 124 return status; 127 125 } 128 126
+2 -4
drivers/acpi/scan.c
··· 28 28 static void acpi_device_release(struct kobject *kobj) 29 29 { 30 30 struct acpi_device *dev = container_of(kobj, struct acpi_device, kobj); 31 - if (dev->pnp.cid_list) 32 - kfree(dev->pnp.cid_list); 31 + kfree(dev->pnp.cid_list); 33 32 kfree(dev); 34 33 } 35 34 ··· 1116 1117 if (!result) 1117 1118 *child = device; 1118 1119 else { 1119 - if (device->pnp.cid_list) 1120 - kfree(device->pnp.cid_list); 1120 + kfree(device->pnp.cid_list); 1121 1121 kfree(device); 1122 1122 } 1123 1123
+4 -8
drivers/acpi/video.c
··· 334 334 return_VALUE(0); 335 335 336 336 err: 337 - if (buffer.pointer) 338 - kfree(buffer.pointer); 337 + kfree(buffer.pointer); 339 338 340 339 return_VALUE(status); 341 340 } ··· 1487 1488 } 1488 1489 active_device_list[count].value.int_val = ACPI_VIDEO_HEAD_END; 1489 1490 1490 - if (video->attached_array) 1491 - kfree(video->attached_array); 1491 + kfree(video->attached_array); 1492 1492 1493 1493 video->attached_array = active_device_list; 1494 1494 video->attached_count = count; ··· 1643 1645 printk(KERN_WARNING PREFIX 1644 1646 "hhuuhhuu bug in acpi video driver.\n"); 1645 1647 1646 - if (data->brightness) 1647 - kfree(data->brightness); 1648 + kfree(data->brightness); 1648 1649 1649 1650 kfree(data); 1650 1651 } ··· 1828 1831 acpi_video_bus_put_devices(video); 1829 1832 acpi_video_bus_remove_fs(device); 1830 1833 1831 - if (video->attached_array) 1832 - kfree(video->attached_array); 1834 + kfree(video->attached_array); 1833 1835 kfree(video); 1834 1836 1835 1837 return_VALUE(0);
+11 -20
drivers/block/DAC960.c
··· 417 417 * Remember the beginning of the group, but don't free it 418 418 * until we've reached the beginning of the next group. 419 419 */ 420 - if (CommandGroup != NULL) 421 - kfree(CommandGroup); 422 - CommandGroup = Command; 420 + kfree(CommandGroup); 421 + CommandGroup = Command; 423 422 } 424 423 Controller->Commands[i] = NULL; 425 424 } 426 - if (CommandGroup != NULL) 427 - kfree(CommandGroup); 425 + kfree(CommandGroup); 428 426 429 427 if (Controller->CombinedStatusBuffer != NULL) 430 428 { ··· 433 435 434 436 if (ScatterGatherPool != NULL) 435 437 pci_pool_destroy(ScatterGatherPool); 436 - if (Controller->FirmwareType == DAC960_V1_Controller) return; 438 + if (Controller->FirmwareType == DAC960_V1_Controller) 439 + return; 437 440 438 441 if (RequestSensePool != NULL) 439 442 pci_pool_destroy(RequestSensePool); 440 443 441 - for (i = 0; i < DAC960_MaxLogicalDrives; i++) 442 - if (Controller->V2.LogicalDeviceInformation[i] != NULL) 443 - { 444 + for (i = 0; i < DAC960_MaxLogicalDrives; i++) { 444 445 kfree(Controller->V2.LogicalDeviceInformation[i]); 445 446 Controller->V2.LogicalDeviceInformation[i] = NULL; 446 - } 447 + } 447 448 448 449 for (i = 0; i < DAC960_V2_MaxPhysicalDevices; i++) 449 450 { 450 - if (Controller->V2.PhysicalDeviceInformation[i] != NULL) 451 - { 452 - kfree(Controller->V2.PhysicalDeviceInformation[i]); 453 - Controller->V2.PhysicalDeviceInformation[i] = NULL; 454 - } 455 - if (Controller->V2.InquiryUnitSerialNumber[i] != NULL) 456 - { 457 - kfree(Controller->V2.InquiryUnitSerialNumber[i]); 458 - Controller->V2.InquiryUnitSerialNumber[i] = NULL; 459 - } 451 + kfree(Controller->V2.PhysicalDeviceInformation[i]); 452 + Controller->V2.PhysicalDeviceInformation[i] = NULL; 453 + kfree(Controller->V2.InquiryUnitSerialNumber[i]); 454 + Controller->V2.InquiryUnitSerialNumber[i] = NULL; 460 455 } 461 456 } 462 457
+4 -8
drivers/block/cciss.c
··· 1096 1096 cleanup1: 1097 1097 if (buff) { 1098 1098 for(i=0; i<sg_used; i++) 1099 - if(buff[i] != NULL) 1100 - kfree(buff[i]); 1099 + kfree(buff[i]); 1101 1100 kfree(buff); 1102 1101 } 1103 - if (buff_size) 1104 - kfree(buff_size); 1105 - if (ioc) 1106 - kfree(ioc); 1102 + kfree(buff_size); 1103 + kfree(ioc); 1107 1104 return(status); 1108 1105 } 1109 1106 default: ··· 3031 3034 return(1); 3032 3035 3033 3036 clean4: 3034 - if(hba[i]->cmd_pool_bits) 3035 - kfree(hba[i]->cmd_pool_bits); 3037 + kfree(hba[i]->cmd_pool_bits); 3036 3038 if(hba[i]->cmd_pool) 3037 3039 pci_free_consistent(hba[i]->pdev, 3038 3040 NR_CMDS * sizeof(CommandList_struct),
+2 -3
drivers/fc4/fc.c
··· 554 554 l->logi = kzalloc (count * 3 * sizeof(logi), GFP_KERNEL); 555 555 l->fcmds = kzalloc (count * sizeof(fcp_cmnd), GFP_KERNEL); 556 556 if (!l->logi || !l->fcmds) { 557 - if (l->logi) kfree (l->logi); 558 - if (l->fcmds) kfree (l->fcmds); 557 + kfree (l->logi); 558 + kfree (l->fcmds); 559 559 kfree (l); 560 560 printk ("FC: Cannot allocate DMA memory for initialization\n"); 561 561 return -ENOMEM; ··· 674 674 atomic_set (&l.todo, count); 675 675 l.fcmds = kzalloc (count * sizeof(fcp_cmnd), GFP_KERNEL); 676 676 if (!l.fcmds) { 677 - kfree (l.fcmds); 678 677 printk ("FC: Cannot allocate memory for forcing offline\n"); 679 678 return -ENOMEM; 680 679 }
+2 -4
drivers/hwmon/w83781d.c
··· 976 976 ERROR_SC_3: 977 977 i2c_detach_client(data->lm75[0]); 978 978 ERROR_SC_2: 979 - if (data->lm75[1]) 980 - kfree(data->lm75[1]); 979 + kfree(data->lm75[1]); 981 980 ERROR_SC_1: 982 - if (data->lm75[0]) 983 - kfree(data->lm75[0]); 981 + kfree(data->lm75[0]); 984 982 ERROR_SC_0: 985 983 return err; 986 984 }
+2 -4
drivers/i2c/busses/i2c-amd756-s4882.c
··· 245 245 kfree(s4882_adapter); 246 246 s4882_adapter = NULL; 247 247 } 248 - if (s4882_algo) { 249 - kfree(s4882_algo); 250 - s4882_algo = NULL; 251 - } 248 + kfree(s4882_algo); 249 + s4882_algo = NULL; 252 250 253 251 /* Restore physical bus */ 254 252 if (i2c_add_adapter(&amd756_smbus))
+6 -12
drivers/ide/ide-cd.c
··· 3292 3292 ide_drive_t *drive = info->drive; 3293 3293 struct gendisk *g = info->disk; 3294 3294 3295 - if (info->buffer != NULL) 3296 - kfree(info->buffer); 3297 - if (info->toc != NULL) 3298 - kfree(info->toc); 3299 - if (info->changer_info != NULL) 3300 - kfree(info->changer_info); 3295 + kfree(info->buffer); 3296 + kfree(info->toc); 3297 + kfree(info->changer_info); 3301 3298 if (devinfo->handle == drive && unregister_cdrom(devinfo)) 3302 3299 printk(KERN_ERR "%s: %s failed to unregister device from the cdrom " 3303 3300 "driver.\n", __FUNCTION__, drive->name); ··· 3484 3487 if (ide_cdrom_setup(drive)) { 3485 3488 struct cdrom_device_info *devinfo = &info->devinfo; 3486 3489 ide_unregister_subdriver(drive, &ide_cdrom_driver); 3487 - if (info->buffer != NULL) 3488 - kfree(info->buffer); 3489 - if (info->toc != NULL) 3490 - kfree(info->toc); 3491 - if (info->changer_info != NULL) 3492 - kfree(info->changer_info); 3490 + kfree(info->buffer); 3491 + kfree(info->toc); 3492 + kfree(info->changer_info); 3493 3493 if (devinfo->handle == drive && unregister_cdrom(devinfo)) 3494 3494 printk (KERN_ERR "%s: ide_cdrom_cleanup failed to unregister device from the cdrom driver.\n", drive->name); 3495 3495 kfree(info);
+2 -4
drivers/ide/ide-probe.c
··· 1315 1315 drive->devfs_name[0] = '\0'; 1316 1316 } 1317 1317 ide_remove_drive_from_hwgroup(drive); 1318 - if (drive->id != NULL) { 1319 - kfree(drive->id); 1320 - drive->id = NULL; 1321 - } 1318 + kfree(drive->id); 1319 + drive->id = NULL; 1322 1320 drive->present = 0; 1323 1321 /* Messed up locking ... */ 1324 1322 spin_unlock_irq(&ide_lock);
+2 -4
drivers/ide/ide-taskfile.c
··· 646 646 } 647 647 abort: 648 648 kfree(req_task); 649 - if (outbuf != NULL) 650 - kfree(outbuf); 651 - if (inbuf != NULL) 652 - kfree(inbuf); 649 + kfree(outbuf); 650 + kfree(inbuf); 653 651 654 652 // printk("IDE Taskfile ioctl ended. rc = %i\n", err); 655 653
+1 -2
drivers/ide/ide.c
··· 888 888 return 0; 889 889 abort: 890 890 up(&ide_setting_sem); 891 - if (setting) 892 - kfree(setting); 891 + kfree(setting); 893 892 return -1; 894 893 } 895 894
+2 -4
drivers/infiniband/core/mad.c
··· 508 508 wait_event(mad_agent_priv->wait, 509 509 !atomic_read(&mad_agent_priv->refcount)); 510 510 511 - if (mad_agent_priv->reg_req) 512 - kfree(mad_agent_priv->reg_req); 511 + kfree(mad_agent_priv->reg_req); 513 512 ib_dereg_mr(mad_agent_priv->agent.mr); 514 513 kfree(mad_agent_priv); 515 514 } ··· 2499 2500 static void destroy_mad_qp(struct ib_mad_qp_info *qp_info) 2500 2501 { 2501 2502 ib_destroy_qp(qp_info->qp); 2502 - if (qp_info->snoop_table) 2503 - kfree(qp_info->snoop_table); 2503 + kfree(qp_info->snoop_table); 2504 2504 } 2505 2505 2506 2506 /*
+3 -7
drivers/input/misc/uinput.c
··· 271 271 goto exit; 272 272 } 273 273 274 - if (dev->name) 275 - kfree(dev->name); 274 + kfree(dev->name); 276 275 277 276 size = strnlen(user_dev->name, UINPUT_MAX_NAME_SIZE) + 1; 278 277 dev->name = name = kmalloc(size, GFP_KERNEL); ··· 371 372 if (test_bit(UIST_CREATED, &udev->state)) 372 373 uinput_destroy_device(udev); 373 374 374 - if (udev->dev->name) 375 - kfree(udev->dev->name); 376 - if (udev->dev->phys) 377 - kfree(udev->dev->phys); 378 - 375 + kfree(udev->dev->name); 376 + kfree(udev->dev->phys); 379 377 kfree(udev->dev); 380 378 kfree(udev); 381 379
+1 -2
drivers/macintosh/adbhid.c
··· 857 857 static void adbhid_input_unregister(int id) 858 858 { 859 859 input_unregister_device(adbhid[id]->input); 860 - if (adbhid[id]->keycode) 861 - kfree(adbhid[id]->keycode); 860 + kfree(adbhid[id]->keycode); 862 861 kfree(adbhid[id]); 863 862 adbhid[id] = NULL; 864 863 }
+1 -2
drivers/mmc/wbsd.c
··· 1602 1602 if (host->dma_addr) 1603 1603 dma_unmap_single(host->mmc->dev, host->dma_addr, WBSD_DMA_SIZE, 1604 1604 DMA_BIDIRECTIONAL); 1605 - if (host->dma_buffer) 1606 - kfree(host->dma_buffer); 1605 + kfree(host->dma_buffer); 1607 1606 if (host->dma >= 0) 1608 1607 free_dma(host->dma); 1609 1608
+10 -11
drivers/parport/probe.c
··· 78 78 u++; 79 79 } 80 80 if (!strcmp(p, "MFG") || !strcmp(p, "MANUFACTURER")) { 81 - if (info->mfr) 82 - kfree (info->mfr); 81 + kfree(info->mfr); 83 82 info->mfr = kstrdup(sep, GFP_KERNEL); 84 83 } else if (!strcmp(p, "MDL") || !strcmp(p, "MODEL")) { 85 - if (info->model) 86 - kfree (info->model); 84 + kfree(info->model); 87 85 info->model = kstrdup(sep, GFP_KERNEL); 88 86 } else if (!strcmp(p, "CLS") || !strcmp(p, "CLASS")) { 89 87 int i; 90 - if (info->class_name) 91 - kfree (info->class_name); 88 + 89 + kfree(info->class_name); 92 90 info->class_name = kstrdup(sep, GFP_KERNEL); 93 91 for (u = sep; *u; u++) 94 92 *u = toupper(*u); ··· 100 102 info->class = PARPORT_CLASS_OTHER; 101 103 } else if (!strcmp(p, "CMD") || 102 104 !strcmp(p, "COMMAND SET")) { 103 - if (info->cmdset) 104 - kfree (info->cmdset); 105 + kfree(info->cmdset); 105 106 info->cmdset = kstrdup(sep, GFP_KERNEL); 106 107 /* if it speaks printer language, it's 107 108 probably a printer */ 108 109 if (strstr(sep, "PJL") || strstr(sep, "PCL")) 109 110 guessed_class = PARPORT_CLASS_PRINTER; 110 111 } else if (!strcmp(p, "DES") || !strcmp(p, "DESCRIPTION")) { 111 - if (info->description) 112 - kfree (info->description); 112 + kfree(info->description); 113 113 info->description = kstrdup(sep, GFP_KERNEL); 114 114 } 115 115 } 116 116 rock_on: 117 - if (q) p = q+1; else p=NULL; 117 + if (q) 118 + p = q + 1; 119 + else 120 + p = NULL; 118 121 } 119 122 120 123 /* If the device didn't tell us its class, maybe we have managed to
+7 -12
drivers/parport/share.c
··· 202 202 list_del(&port->full_list); 203 203 spin_unlock(&full_list_lock); 204 204 for (d = 0; d < 5; d++) { 205 - if (port->probe_info[d].class_name) 206 - kfree (port->probe_info[d].class_name); 207 - if (port->probe_info[d].mfr) 208 - kfree (port->probe_info[d].mfr); 209 - if (port->probe_info[d].model) 210 - kfree (port->probe_info[d].model); 211 - if (port->probe_info[d].cmdset) 212 - kfree (port->probe_info[d].cmdset); 213 - if (port->probe_info[d].description) 214 - kfree (port->probe_info[d].description); 205 + kfree(port->probe_info[d].class_name); 206 + kfree(port->probe_info[d].mfr); 207 + kfree(port->probe_info[d].model); 208 + kfree(port->probe_info[d].cmdset); 209 + kfree(port->probe_info[d].description); 215 210 } 216 211 217 212 kfree(port->name); ··· 613 618 return tmp; 614 619 615 620 out_free_all: 616 - kfree (tmp->state); 621 + kfree(tmp->state); 617 622 out_free_pardevice: 618 - kfree (tmp); 623 + kfree(tmp); 619 624 out: 620 625 parport_put_port (port); 621 626 module_put(port->ops->owner);
+5 -10
drivers/pci/hotplug/cpqphp_pci.c
··· 259 259 sizeof(struct irq_routing_table)) / sizeof(struct irq_info); 260 260 // Make sure I got at least one entry 261 261 if (len == 0) { 262 - if (PCIIRQRoutingInfoLength != NULL) 263 - kfree(PCIIRQRoutingInfoLength ); 262 + kfree(PCIIRQRoutingInfoLength ); 264 263 return -1; 265 264 } 266 265 ··· 274 275 ctrl->pci_bus->number = tbus; 275 276 pci_bus_read_config_dword (ctrl->pci_bus, *dev_num, PCI_VENDOR_ID, &work); 276 277 if (!nobridge || (work == 0xffffffff)) { 277 - if (PCIIRQRoutingInfoLength != NULL) 278 - kfree(PCIIRQRoutingInfoLength ); 278 + kfree(PCIIRQRoutingInfoLength ); 279 279 return 0; 280 280 } 281 281 ··· 287 289 dbg("Scan bus for Non Bridge: bus %d\n", tbus); 288 290 if (PCI_ScanBusForNonBridge(ctrl, tbus, dev_num) == 0) { 289 291 *bus_num = tbus; 290 - if (PCIIRQRoutingInfoLength != NULL) 291 - kfree(PCIIRQRoutingInfoLength ); 292 + kfree(PCIIRQRoutingInfoLength ); 292 293 return 0; 293 294 } 294 295 } else { 295 - if (PCIIRQRoutingInfoLength != NULL) 296 - kfree(PCIIRQRoutingInfoLength ); 296 + kfree(PCIIRQRoutingInfoLength ); 297 297 return 0; 298 298 } 299 299 300 300 } 301 301 } 302 - if (PCIIRQRoutingInfoLength != NULL) 303 - kfree(PCIIRQRoutingInfoLength ); 302 + kfree(PCIIRQRoutingInfoLength ); 304 303 return -1; 305 304 } 306 305
+4 -8
drivers/pcmcia/cistpl.c
··· 334 334 /* 335 335 * If there was a fake CIS, destroy that as well. 336 336 */ 337 - if (s->fake_cis) { 338 - kfree(s->fake_cis); 339 - s->fake_cis = NULL; 340 - } 337 + kfree(s->fake_cis); 338 + s->fake_cis = NULL; 341 339 } 342 340 EXPORT_SYMBOL(destroy_cis_cache); 343 341 ··· 384 386 385 387 int pcmcia_replace_cis(struct pcmcia_socket *s, cisdump_t *cis) 386 388 { 387 - if (s->fake_cis != NULL) { 388 - kfree(s->fake_cis); 389 - s->fake_cis = NULL; 390 - } 389 + kfree(s->fake_cis); 390 + s->fake_cis = NULL; 391 391 if (cis->Length > CISTPL_MAX_CIS_SIZE) 392 392 return CS_BAD_SIZE; 393 393 s->fake_cis = kmalloc(cis->Length, GFP_KERNEL);
+2 -4
drivers/pcmcia/cs.c
··· 331 331 cb_free(s); 332 332 #endif 333 333 s->functions = 0; 334 - if (s->config) { 335 - kfree(s->config); 336 - s->config = NULL; 337 - } 334 + kfree(s->config); 335 + s->config = NULL; 338 336 339 337 { 340 338 int status;
+5 -8
drivers/sbus/char/envctrl.c
··· 1125 1125 misc_deregister(&envctrl_dev); 1126 1126 out_iounmap: 1127 1127 iounmap(i2c); 1128 - for (i = 0; i < ENVCTRL_MAX_CPU * 2; i++) { 1129 - if (i2c_childlist[i].tables) 1130 - kfree(i2c_childlist[i].tables); 1131 - } 1128 + for (i = 0; i < ENVCTRL_MAX_CPU * 2; i++) 1129 + kfree(i2c_childlist[i].tables); 1130 + 1132 1131 return err; 1133 1132 } 1134 1133 ··· 1140 1141 iounmap(i2c); 1141 1142 misc_deregister(&envctrl_dev); 1142 1143 1143 - for (i = 0; i < ENVCTRL_MAX_CPU * 2; i++) { 1144 - if (i2c_childlist[i].tables) 1145 - kfree(i2c_childlist[i].tables); 1146 - } 1144 + for (i = 0; i < ENVCTRL_MAX_CPU * 2; i++) 1145 + kfree(i2c_childlist[i].tables); 1147 1146 } 1148 1147 1149 1148 module_init(envctrl_init);
+1 -2
drivers/video/i810/i810_main.c
··· 2057 2057 iounmap(par->mmio_start_virtual); 2058 2058 if (par->aperture.virtual) 2059 2059 iounmap(par->aperture.virtual); 2060 - if (par->edid) 2061 - kfree(par->edid); 2060 + kfree(par->edid); 2062 2061 if (par->res_flags & FRAMEBUFFER_REQ) 2063 2062 release_mem_region(par->aperture.physical, 2064 2063 par->aperture.size);
+2 -4
drivers/w1/w1_ds2433.c
··· 299 299 static void w1_f23_remove_slave(struct w1_slave *sl) 300 300 { 301 301 #ifdef CONFIG_W1_F23_CRC 302 - if (sl->family_data) { 303 - kfree(sl->family_data); 304 - sl->family_data = NULL; 305 - } 302 + kfree(sl->family_data); 303 + sl->family_data = NULL; 306 304 #endif /* CONFIG_W1_F23_CRC */ 307 305 sysfs_remove_bin_file(&sl->dev.kobj, &w1_f23_bin_attr); 308 306 }