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>
 {
        acpi_status status = AE_OK;
        struct acpi_container *pc = NULL;
-       pc = (struct acpi_container *)acpi_driver_data(device);
-
-       if (pc)
-               kfree(pc);
 
+       pc = (struct acpi_container *)acpi_driver_data(device);
+       kfree(pc);
        return status;
 }
 
 
 static void acpi_device_release(struct kobject *kobj)
 {
        struct acpi_device *dev = container_of(kobj, struct acpi_device, kobj);
-       if (dev->pnp.cid_list)
-               kfree(dev->pnp.cid_list);
+       kfree(dev->pnp.cid_list);
        kfree(dev);
 }
 
        if (!result)
                *child = device;
        else {
-               if (device->pnp.cid_list)
-                       kfree(device->pnp.cid_list);
+               kfree(device->pnp.cid_list);
                kfree(device);
        }
 
 
        return_VALUE(0);
 
       err:
-       if (buffer.pointer)
-               kfree(buffer.pointer);
+       kfree(buffer.pointer);
 
        return_VALUE(status);
 }
        }
        active_device_list[count].value.int_val = ACPI_VIDEO_HEAD_END;
 
-       if (video->attached_array)
-               kfree(video->attached_array);
+       kfree(video->attached_array);
 
        video->attached_array = active_device_list;
        video->attached_count = count;
                        printk(KERN_WARNING PREFIX
                               "hhuuhhuu bug in acpi video driver.\n");
 
-               if (data->brightness)
-                       kfree(data->brightness);
+               kfree(data->brightness);
 
                kfree(data);
        }
        acpi_video_bus_put_devices(video);
        acpi_video_bus_remove_fs(device);
 
-       if (video->attached_array)
-               kfree(video->attached_array);
+       kfree(video->attached_array);
        kfree(video);
 
        return_VALUE(0);
 
             * Remember the beginning of the group, but don't free it
            * until we've reached the beginning of the next group.
            */
-          if (CommandGroup != NULL)
-               kfree(CommandGroup);
-           CommandGroup = Command;
+          kfree(CommandGroup);
+          CommandGroup = Command;
       }
       Controller->Commands[i] = NULL;
     }
-  if (CommandGroup != NULL)
-      kfree(CommandGroup);
+  kfree(CommandGroup);
 
   if (Controller->CombinedStatusBuffer != NULL)
     {
 
   if (ScatterGatherPool != NULL)
        pci_pool_destroy(ScatterGatherPool);
-  if (Controller->FirmwareType == DAC960_V1_Controller) return;
+  if (Controller->FirmwareType == DAC960_V1_Controller)
+       return;
 
   if (RequestSensePool != NULL)
        pci_pool_destroy(RequestSensePool);
 
-  for (i = 0; i < DAC960_MaxLogicalDrives; i++)
-    if (Controller->V2.LogicalDeviceInformation[i] != NULL)
-      {
+  for (i = 0; i < DAC960_MaxLogicalDrives; i++) {
        kfree(Controller->V2.LogicalDeviceInformation[i]);
        Controller->V2.LogicalDeviceInformation[i] = NULL;
-      }
+  }
 
   for (i = 0; i < DAC960_V2_MaxPhysicalDevices; i++)
     {
-      if (Controller->V2.PhysicalDeviceInformation[i] != NULL)
-       {
-         kfree(Controller->V2.PhysicalDeviceInformation[i]);
-         Controller->V2.PhysicalDeviceInformation[i] = NULL;
-       }
-      if (Controller->V2.InquiryUnitSerialNumber[i] != NULL)
-       {
-         kfree(Controller->V2.InquiryUnitSerialNumber[i]);
-         Controller->V2.InquiryUnitSerialNumber[i] = NULL;
-       }
+      kfree(Controller->V2.PhysicalDeviceInformation[i]);
+      Controller->V2.PhysicalDeviceInformation[i] = NULL;
+      kfree(Controller->V2.InquiryUnitSerialNumber[i]);
+      Controller->V2.InquiryUnitSerialNumber[i] = NULL;
     }
 }
 
 
 cleanup1:
                if (buff) {
                        for(i=0; i<sg_used; i++)
-                               if(buff[i] != NULL)
-                                       kfree(buff[i]);
+                               kfree(buff[i]);
                        kfree(buff);
                }
-               if (buff_size)
-                       kfree(buff_size);
-               if (ioc)
-                       kfree(ioc);
+               kfree(buff_size);
+               kfree(ioc);
                return(status);
        }
        default:
        return(1);
 
 clean4:
-       if(hba[i]->cmd_pool_bits)
-                       kfree(hba[i]->cmd_pool_bits);
+       kfree(hba[i]->cmd_pool_bits);
        if(hba[i]->cmd_pool)
                pci_free_consistent(hba[i]->pdev,
                        NR_CMDS * sizeof(CommandList_struct),
 
        l->logi = kzalloc (count * 3 * sizeof(logi), GFP_KERNEL);
        l->fcmds = kzalloc (count * sizeof(fcp_cmnd), GFP_KERNEL);
        if (!l->logi || !l->fcmds) {
-               if (l->logi) kfree (l->logi);
-               if (l->fcmds) kfree (l->fcmds);
+               kfree (l->logi);
+               kfree (l->fcmds);
                kfree (l);
                printk ("FC: Cannot allocate DMA memory for initialization\n");
                return -ENOMEM;
        atomic_set (&l.todo, count);
        l.fcmds = kzalloc (count * sizeof(fcp_cmnd), GFP_KERNEL);
        if (!l.fcmds) {
-               kfree (l.fcmds);
                printk ("FC: Cannot allocate memory for forcing offline\n");
                return -ENOMEM;
        }
 
 ERROR_SC_3:
        i2c_detach_client(data->lm75[0]);
 ERROR_SC_2:
-       if (data->lm75[1])
-               kfree(data->lm75[1]);
+       kfree(data->lm75[1]);
 ERROR_SC_1:
-       if (data->lm75[0])
-               kfree(data->lm75[0]);
+       kfree(data->lm75[0]);
 ERROR_SC_0:
        return err;
 }
 
                kfree(s4882_adapter);
                s4882_adapter = NULL;
        }
-       if (s4882_algo) {
-               kfree(s4882_algo);
-               s4882_algo = NULL;
-       }
+       kfree(s4882_algo);
+       s4882_algo = NULL;
 
        /* Restore physical bus */
        if (i2c_add_adapter(&amd756_smbus))
 
        ide_drive_t *drive = info->drive;
        struct gendisk *g = info->disk;
 
-       if (info->buffer != NULL)
-               kfree(info->buffer);
-       if (info->toc != NULL)
-               kfree(info->toc);
-       if (info->changer_info != NULL)
-               kfree(info->changer_info);
+       kfree(info->buffer);
+       kfree(info->toc);
+       kfree(info->changer_info);
        if (devinfo->handle == drive && unregister_cdrom(devinfo))
                printk(KERN_ERR "%s: %s failed to unregister device from the cdrom "
                                "driver.\n", __FUNCTION__, drive->name);
        if (ide_cdrom_setup(drive)) {
                struct cdrom_device_info *devinfo = &info->devinfo;
                ide_unregister_subdriver(drive, &ide_cdrom_driver);
-               if (info->buffer != NULL)
-                       kfree(info->buffer);
-               if (info->toc != NULL)
-                       kfree(info->toc);
-               if (info->changer_info != NULL)
-                       kfree(info->changer_info);
+               kfree(info->buffer);
+               kfree(info->toc);
+               kfree(info->changer_info);
                if (devinfo->handle == drive && unregister_cdrom(devinfo))
                        printk (KERN_ERR "%s: ide_cdrom_cleanup failed to unregister device from the cdrom driver.\n", drive->name);
                kfree(info);
 
                drive->devfs_name[0] = '\0';
        }
        ide_remove_drive_from_hwgroup(drive);
-       if (drive->id != NULL) {
-               kfree(drive->id);
-               drive->id = NULL;
-       }
+       kfree(drive->id);
+       drive->id = NULL;
        drive->present = 0;
        /* Messed up locking ... */
        spin_unlock_irq(&ide_lock);
 
        }
 abort:
        kfree(req_task);
-       if (outbuf != NULL)
-               kfree(outbuf);
-       if (inbuf != NULL)
-               kfree(inbuf);
+       kfree(outbuf);
+       kfree(inbuf);
 
 //     printk("IDE Taskfile ioctl ended. rc = %i\n", err);
 
 
        return 0;
 abort:
        up(&ide_setting_sem);
-       if (setting)
-               kfree(setting);
+       kfree(setting);
        return -1;
 }
 
 
        wait_event(mad_agent_priv->wait,
                   !atomic_read(&mad_agent_priv->refcount));
 
-       if (mad_agent_priv->reg_req)
-               kfree(mad_agent_priv->reg_req);
+       kfree(mad_agent_priv->reg_req);
        ib_dereg_mr(mad_agent_priv->agent.mr);
        kfree(mad_agent_priv);
 }
 static void destroy_mad_qp(struct ib_mad_qp_info *qp_info)
 {
        ib_destroy_qp(qp_info->qp);
-       if (qp_info->snoop_table)
-               kfree(qp_info->snoop_table);
+       kfree(qp_info->snoop_table);
 }
 
 /*
 
                goto exit;
        }
 
-       if (dev->name)
-               kfree(dev->name);
+       kfree(dev->name);
 
        size = strnlen(user_dev->name, UINPUT_MAX_NAME_SIZE) + 1;
        dev->name = name = kmalloc(size, GFP_KERNEL);
        if (test_bit(UIST_CREATED, &udev->state))
                uinput_destroy_device(udev);
 
-       if (udev->dev->name)
-               kfree(udev->dev->name);
-       if (udev->dev->phys)
-               kfree(udev->dev->phys);
-
+       kfree(udev->dev->name);
+       kfree(udev->dev->phys);
        kfree(udev->dev);
        kfree(udev);
 
 
 static void adbhid_input_unregister(int id)
 {
        input_unregister_device(adbhid[id]->input);
-       if (adbhid[id]->keycode)
-               kfree(adbhid[id]->keycode);
+       kfree(adbhid[id]->keycode);
        kfree(adbhid[id]);
        adbhid[id] = NULL;
 }
 
        if (host->dma_addr)
                dma_unmap_single(host->mmc->dev, host->dma_addr, WBSD_DMA_SIZE,
                        DMA_BIDIRECTIONAL);
-       if (host->dma_buffer)
-               kfree(host->dma_buffer);
+       kfree(host->dma_buffer);
        if (host->dma >= 0)
                free_dma(host->dma);
 
 
                                u++;
                        }
                        if (!strcmp(p, "MFG") || !strcmp(p, "MANUFACTURER")) {
-                               if (info->mfr)
-                                       kfree (info->mfr);
+                               kfree(info->mfr);
                                info->mfr = kstrdup(sep, GFP_KERNEL);
                        } else if (!strcmp(p, "MDL") || !strcmp(p, "MODEL")) {
-                               if (info->model)
-                                       kfree (info->model);
+                               kfree(info->model);
                                info->model = kstrdup(sep, GFP_KERNEL);
                        } else if (!strcmp(p, "CLS") || !strcmp(p, "CLASS")) {
                                int i;
-                               if (info->class_name)
-                                       kfree (info->class_name);
+
+                               kfree(info->class_name);
                                info->class_name = kstrdup(sep, GFP_KERNEL);
                                for (u = sep; *u; u++)
                                        *u = toupper(*u);
                                info->class = PARPORT_CLASS_OTHER;
                        } else if (!strcmp(p, "CMD") ||
                                   !strcmp(p, "COMMAND SET")) {
-                               if (info->cmdset)
-                                       kfree (info->cmdset);
+                               kfree(info->cmdset);
                                info->cmdset = kstrdup(sep, GFP_KERNEL);
                                /* if it speaks printer language, it's
                                   probably a printer */
                                if (strstr(sep, "PJL") || strstr(sep, "PCL"))
                                        guessed_class = PARPORT_CLASS_PRINTER;
                        } else if (!strcmp(p, "DES") || !strcmp(p, "DESCRIPTION")) {
-                               if (info->description)
-                                       kfree (info->description);
+                               kfree(info->description);
                                info->description = kstrdup(sep, GFP_KERNEL);
                        }
                }
        rock_on:
-               if (q) p = q+1; else p=NULL;
+               if (q)
+                       p = q + 1;
+               else
+                       p = NULL;
        }
 
        /* If the device didn't tell us its class, maybe we have managed to
 
        list_del(&port->full_list);
        spin_unlock(&full_list_lock);
        for (d = 0; d < 5; d++) {
-               if (port->probe_info[d].class_name)
-                       kfree (port->probe_info[d].class_name);
-               if (port->probe_info[d].mfr)
-                       kfree (port->probe_info[d].mfr);
-               if (port->probe_info[d].model)
-                       kfree (port->probe_info[d].model);
-               if (port->probe_info[d].cmdset)
-                       kfree (port->probe_info[d].cmdset);
-               if (port->probe_info[d].description)
-                       kfree (port->probe_info[d].description);
+               kfree(port->probe_info[d].class_name);
+               kfree(port->probe_info[d].mfr);
+               kfree(port->probe_info[d].model);
+               kfree(port->probe_info[d].cmdset);
+               kfree(port->probe_info[d].description);
        }
 
        kfree(port->name);
        return tmp;
 
  out_free_all:
-       kfree (tmp->state);
+       kfree(tmp->state);
  out_free_pardevice:
-       kfree (tmp);
+       kfree(tmp);
  out:
        parport_put_port (port);
        module_put(port->ops->owner);
 
               sizeof(struct irq_routing_table)) / sizeof(struct irq_info);
        // Make sure I got at least one entry
        if (len == 0) {
-               if (PCIIRQRoutingInfoLength != NULL)
-                       kfree(PCIIRQRoutingInfoLength );
+               kfree(PCIIRQRoutingInfoLength );
                return -1;
        }
 
                        ctrl->pci_bus->number = tbus;
                        pci_bus_read_config_dword (ctrl->pci_bus, *dev_num, PCI_VENDOR_ID, &work);
                        if (!nobridge || (work == 0xffffffff)) {
-                               if (PCIIRQRoutingInfoLength != NULL)
-                                       kfree(PCIIRQRoutingInfoLength );
+                               kfree(PCIIRQRoutingInfoLength );
                                return 0;
                        }
 
                                dbg("Scan bus for Non Bridge: bus %d\n", tbus);
                                if (PCI_ScanBusForNonBridge(ctrl, tbus, dev_num) == 0) {
                                        *bus_num = tbus;
-                                       if (PCIIRQRoutingInfoLength != NULL)
-                                               kfree(PCIIRQRoutingInfoLength );
+                                       kfree(PCIIRQRoutingInfoLength );
                                        return 0;
                                }
                        } else {
-                               if (PCIIRQRoutingInfoLength != NULL)
-                                       kfree(PCIIRQRoutingInfoLength );
+                               kfree(PCIIRQRoutingInfoLength );
                                return 0;
                        }
 
                }
        }
-       if (PCIIRQRoutingInfoLength != NULL)
-               kfree(PCIIRQRoutingInfoLength );
+       kfree(PCIIRQRoutingInfoLength );
        return -1;
 }
 
 
        /*
         * If there was a fake CIS, destroy that as well.
         */
-       if (s->fake_cis) {
-               kfree(s->fake_cis);
-               s->fake_cis = NULL;
-       }
+       kfree(s->fake_cis);
+       s->fake_cis = NULL;
 }
 EXPORT_SYMBOL(destroy_cis_cache);
 
 
 int pcmcia_replace_cis(struct pcmcia_socket *s, cisdump_t *cis)
 {
-    if (s->fake_cis != NULL) {
-       kfree(s->fake_cis);
-       s->fake_cis = NULL;
-    }
+    kfree(s->fake_cis);
+    s->fake_cis = NULL;
     if (cis->Length > CISTPL_MAX_CIS_SIZE)
        return CS_BAD_SIZE;
     s->fake_cis = kmalloc(cis->Length, GFP_KERNEL);
 
        cb_free(s);
 #endif
        s->functions = 0;
-       if (s->config) {
-               kfree(s->config);
-               s->config = NULL;
-       }
+       kfree(s->config);
+       s->config = NULL;
 
        {
                int status;
 
        misc_deregister(&envctrl_dev);
 out_iounmap:
        iounmap(i2c);
-       for (i = 0; i < ENVCTRL_MAX_CPU * 2; i++) {
-               if (i2c_childlist[i].tables)
-                       kfree(i2c_childlist[i].tables);
-       }
+       for (i = 0; i < ENVCTRL_MAX_CPU * 2; i++)
+               kfree(i2c_childlist[i].tables);
+
        return err;
 }
 
        iounmap(i2c);
        misc_deregister(&envctrl_dev);
 
-       for (i = 0; i < ENVCTRL_MAX_CPU * 2; i++) {
-               if (i2c_childlist[i].tables)
-                       kfree(i2c_childlist[i].tables);
-       }
+       for (i = 0; i < ENVCTRL_MAX_CPU * 2; i++)
+               kfree(i2c_childlist[i].tables);
 }
 
 module_init(envctrl_init);
 
                iounmap(par->mmio_start_virtual);
        if (par->aperture.virtual)
                iounmap(par->aperture.virtual);
-       if (par->edid)
-               kfree(par->edid);
+       kfree(par->edid);
        if (par->res_flags & FRAMEBUFFER_REQ)
                release_mem_region(par->aperture.physical,
                                   par->aperture.size);
 
 static void w1_f23_remove_slave(struct w1_slave *sl)
 {
 #ifdef CONFIG_W1_F23_CRC
-       if (sl->family_data) {
-               kfree(sl->family_data);
-               sl->family_data = NULL;
-       }
+       kfree(sl->family_data);
+       sl->family_data = NULL;
 #endif /* CONFIG_W1_F23_CRC */
        sysfs_remove_bin_file(&sl->dev.kobj, &w1_f23_bin_attr);
 }