[PATCH] USB: kfree cleanup for drivers/usb/* - no need to check for NULL
Jesper Juhl [Tue, 19 Apr 2005 00:39:34 +0000 (17:39 -0700)]
Get rid of a bunch of redundant NULL pointer checks in drivers/usb/*,
there's no need to check a pointer for NULL before calling kfree() on it.

Signed-off-by: Jesper Juhl <juhl-lkml@dif.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

Index: gregkh-2.6/drivers/usb/class/audio.c
===================================================================

26 files changed:
drivers/usb/class/audio.c
drivers/usb/class/bluetty.c
drivers/usb/core/devices.c
drivers/usb/core/hub.c
drivers/usb/gadget/serial.c
drivers/usb/host/ehci-mem.c
drivers/usb/host/uhci-hcd.c
drivers/usb/input/hid-core.c
drivers/usb/media/dabusb.c
drivers/usb/media/ov511.c
drivers/usb/media/se401.c
drivers/usb/media/usbvideo.c
drivers/usb/media/w9968cf.c
drivers/usb/misc/auerswald.c
drivers/usb/net/zd1201.c
drivers/usb/serial/belkin_sa.c
drivers/usb/serial/cypress_m8.c
drivers/usb/serial/empeg.c
drivers/usb/serial/ftdi_sio.c
drivers/usb/serial/io_edgeport.c
drivers/usb/serial/io_ti.c
drivers/usb/serial/kl5kusb105.c
drivers/usb/serial/omninet.c
drivers/usb/serial/pl2303.c
drivers/usb/serial/ti_usb_3410_5052.c
drivers/usb/storage/sddr55.c

index f432b7d..f8f2156 100644 (file)
@@ -649,14 +649,10 @@ static void usbin_stop(struct usb_audiodev *as)
                }
        }
        set_current_state(TASK_RUNNING);
-       if (u->durb[0].urb->transfer_buffer)
-               kfree(u->durb[0].urb->transfer_buffer);
-       if (u->durb[1].urb->transfer_buffer)
-               kfree(u->durb[1].urb->transfer_buffer);
-       if (u->surb[0].urb->transfer_buffer)
-               kfree(u->surb[0].urb->transfer_buffer);
-       if (u->surb[1].urb->transfer_buffer)
-               kfree(u->surb[1].urb->transfer_buffer);
+       kfree(u->durb[0].urb->transfer_buffer);
+       kfree(u->durb[1].urb->transfer_buffer);
+       kfree(u->surb[0].urb->transfer_buffer);
+       kfree(u->surb[1].urb->transfer_buffer);
        u->durb[0].urb->transfer_buffer = u->durb[1].urb->transfer_buffer = 
                u->surb[0].urb->transfer_buffer = u->surb[1].urb->transfer_buffer = NULL;
 }
@@ -1009,21 +1005,17 @@ static int usbin_start(struct usb_audiodev *as)
                u->phase = 0;
                maxsze = (u->freqmax + 0x3fff) >> (14 - AFMT_BYTESSHIFT(u->format));
                bufsz = DESCFRAMES * maxsze;
-               if (u->durb[0].urb->transfer_buffer)
-                       kfree(u->durb[0].urb->transfer_buffer);
+               kfree(u->durb[0].urb->transfer_buffer);
                u->durb[0].urb->transfer_buffer = kmalloc(bufsz, GFP_KERNEL);
                u->durb[0].urb->transfer_buffer_length = bufsz;
-               if (u->durb[1].urb->transfer_buffer)
-                       kfree(u->durb[1].urb->transfer_buffer);
+               kfree(u->durb[1].urb->transfer_buffer);
                u->durb[1].urb->transfer_buffer = kmalloc(bufsz, GFP_KERNEL);
                u->durb[1].urb->transfer_buffer_length = bufsz;
                if (u->syncpipe) {
-                       if (u->surb[0].urb->transfer_buffer)
-                               kfree(u->surb[0].urb->transfer_buffer);
+                       kfree(u->surb[0].urb->transfer_buffer);
                        u->surb[0].urb->transfer_buffer = kmalloc(3*SYNCFRAMES, GFP_KERNEL);
                        u->surb[0].urb->transfer_buffer_length = 3*SYNCFRAMES;
-                       if (u->surb[1].urb->transfer_buffer)
-                               kfree(u->surb[1].urb->transfer_buffer);
+                       kfree(u->surb[1].urb->transfer_buffer);
                        u->surb[1].urb->transfer_buffer = kmalloc(3*SYNCFRAMES, GFP_KERNEL);
                        u->surb[1].urb->transfer_buffer_length = 3*SYNCFRAMES;
                }
@@ -1128,14 +1120,10 @@ static void usbout_stop(struct usb_audiodev *as)
                }
        }
        set_current_state(TASK_RUNNING);
-       if (u->durb[0].urb->transfer_buffer)
-               kfree(u->durb[0].urb->transfer_buffer);
-       if (u->durb[1].urb->transfer_buffer)
-               kfree(u->durb[1].urb->transfer_buffer);
-       if (u->surb[0].urb->transfer_buffer)
-               kfree(u->surb[0].urb->transfer_buffer);
-       if (u->surb[1].urb->transfer_buffer)
-               kfree(u->surb[1].urb->transfer_buffer);
+       kfree(u->durb[0].urb->transfer_buffer);
+       kfree(u->durb[1].urb->transfer_buffer);
+       kfree(u->surb[0].urb->transfer_buffer);
+       kfree(u->surb[1].urb->transfer_buffer);
        u->durb[0].urb->transfer_buffer = u->durb[1].urb->transfer_buffer = 
                u->surb[0].urb->transfer_buffer = u->surb[1].urb->transfer_buffer = NULL;
 }
@@ -1376,21 +1364,17 @@ static int usbout_start(struct usb_audiodev *as)
                u->phase = 0;
                maxsze = (u->freqmax + 0x3fff) >> (14 - AFMT_BYTESSHIFT(u->format));
                bufsz = DESCFRAMES * maxsze;
-               if (u->durb[0].urb->transfer_buffer)
-                       kfree(u->durb[0].urb->transfer_buffer);
+               kfree(u->durb[0].urb->transfer_buffer);
                u->durb[0].urb->transfer_buffer = kmalloc(bufsz, GFP_KERNEL);
                u->durb[0].urb->transfer_buffer_length = bufsz;
-               if (u->durb[1].urb->transfer_buffer)
-                       kfree(u->durb[1].urb->transfer_buffer);
+               kfree(u->durb[1].urb->transfer_buffer);
                u->durb[1].urb->transfer_buffer = kmalloc(bufsz, GFP_KERNEL);
                u->durb[1].urb->transfer_buffer_length = bufsz;
                if (u->syncpipe) {
-                       if (u->surb[0].urb->transfer_buffer)
-                               kfree(u->surb[0].urb->transfer_buffer);
+                       kfree(u->surb[0].urb->transfer_buffer);
                        u->surb[0].urb->transfer_buffer = kmalloc(3*SYNCFRAMES, GFP_KERNEL);
                        u->surb[0].urb->transfer_buffer_length = 3*SYNCFRAMES;
-                       if (u->surb[1].urb->transfer_buffer)
-                               kfree(u->surb[1].urb->transfer_buffer);
+                       kfree(u->surb[1].urb->transfer_buffer);
                        u->surb[1].urb->transfer_buffer = kmalloc(3*SYNCFRAMES, GFP_KERNEL);
                        u->surb[1].urb->transfer_buffer_length = 3*SYNCFRAMES;
                }
index 6bac65e..5240233 100644 (file)
@@ -309,7 +309,7 @@ static int bluetooth_ctrl_msg (struct usb_bluetooth *bluetooth, int request, int
                }
        }
        if (urb->transfer_buffer_length < len) {
-               kfree (urb->transfer_buffer);
+               kfree(urb->transfer_buffer);
                urb->transfer_buffer = kmalloc (len, GFP_KERNEL);
                if (urb->transfer_buffer == NULL) {
                        err ("%s - out of memory", __FUNCTION__);
@@ -535,7 +535,7 @@ static int bluetooth_write (struct tty_struct * tty, const unsigned char *buf, i
        }
 
 exit:
-       kfree (temp_buffer);
+       kfree(temp_buffer);
 
        return retval;
 } 
index b87608b..ef0b357 100644 (file)
@@ -637,11 +637,8 @@ static int usb_device_open(struct inode *inode, struct file *file)
 
 static int usb_device_release(struct inode *inode, struct file *file)
 {
-       if (file->private_data) {
-               kfree(file->private_data);
-               file->private_data = NULL;
-       }
-
+       kfree(file->private_data);
+       file->private_data = NULL;
         return 0;
 }
 
index 15ac4d1..d2d648e 100644 (file)
@@ -381,7 +381,7 @@ static void hub_tt_kevent (void *arg)
                        dev_err (&hdev->dev,
                                "clear tt %d (%04x) error %d\n",
                                clear->tt, clear->devinfo, status);
-               kfree (clear);
+               kfree(clear);
        }
        spin_unlock_irqrestore (&hub->tt.lock, flags);
 }
@@ -728,15 +728,11 @@ static void hub_disconnect(struct usb_interface *intf)
        list_del_init(&hub->event_list);
        spin_unlock_irq(&hub_event_lock);
 
-       if (hub->descriptor) {
-               kfree(hub->descriptor);
-               hub->descriptor = NULL;
-       }
+       kfree(hub->descriptor);
+       hub->descriptor = NULL;
 
-       if (hub->status) {
-               kfree(hub->status);
-               hub->status = NULL;
-       }
+       kfree(hub->status);
+       hub->status = NULL;
 
        if (hub->buffer) {
                usb_buffer_free(hdev, sizeof(*hub->buffer), hub->buffer,
@@ -2354,7 +2350,7 @@ check_highspeed (struct usb_hub *hub, struct usb_device *udev, int port1)
                        schedule_work (&hub->leds);
                }
        }
-       kfree (qual);
+       kfree(qual);
 }
 
 static unsigned
index 2af3f78..f1762ed 100644 (file)
@@ -2312,9 +2312,8 @@ static struct gs_buf *gs_buf_alloc(unsigned int size, int kmalloc_flags)
  */
 void gs_buf_free(struct gs_buf *gb)
 {
-       if (gb != NULL) {
-               if (gb->buf_buf != NULL)
-                       kfree(gb->buf_buf);
+       if (gb) {
+               kfree(gb->buf_buf);
                kfree(gb);
        }
 }
index 9938697..5c38ad8 100644 (file)
@@ -156,8 +156,7 @@ static void ehci_mem_cleanup (struct ehci_hcd *ehci)
        ehci->periodic = NULL;
 
        /* shadow periodic table */
-       if (ehci->pshadow)
-               kfree (ehci->pshadow);
+       kfree(ehci->pshadow);
        ehci->pshadow = NULL;
 }
 
index 98745a0..49bd83e 100644 (file)
@@ -890,8 +890,7 @@ up_failed:
        debugfs_remove(uhci_debugfs_root);
 
 debug_failed:
-       if (errbuf)
-               kfree(errbuf);
+       kfree(errbuf);
 
 errbuf_failed:
 
@@ -906,9 +905,7 @@ static void __exit uhci_hcd_cleanup(void)
                warn("not all urb_priv's were freed!");
 
        debugfs_remove(uhci_debugfs_root);
-
-       if (errbuf)
-               kfree(errbuf);
+       kfree(errbuf);
 }
 
 module_init(uhci_hcd_init);
index e625997..869ff73 100644 (file)
@@ -558,8 +558,7 @@ static void hid_free_device(struct hid_device *device)
                }
        }
 
-       if (device->rdesc)
-               kfree(device->rdesc);
+       kfree(device->rdesc);
        kfree(device);
 }
 
index 8823297..6ca2fae 100644 (file)
@@ -138,8 +138,7 @@ static int dabusb_free_queue (struct list_head *q)
 #ifdef DEBUG 
                dump_urb(b->purb);
 #endif
-               if (b->purb->transfer_buffer)
-                       kfree (b->purb->transfer_buffer);
+               kfree(b->purb->transfer_buffer);
                usb_free_urb(b->purb);
                tmp = p->next;
                list_del (p);
index 0fd7ffe..d605182 100644 (file)
@@ -3915,10 +3915,8 @@ ov51x_do_dealloc(struct usb_ov511 *ov)
        ov->tempfbuf = NULL;
 
        for (i = 0; i < OV511_NUMSBUF; i++) {
-               if (ov->sbuf[i].data) {
-                       kfree(ov->sbuf[i].data);
-                       ov->sbuf[i].data = NULL;
-               }
+               kfree(ov->sbuf[i].data);
+               ov->sbuf[i].data = NULL;
        }
 
        for (i = 0; i < OV511_NUMFRAMES; i++) {
@@ -5954,10 +5952,8 @@ error:
                up(&ov->cbuf_lock);
        }
 
-       if (ov) {
-               kfree(ov);
-               ov = NULL;
-       }
+       kfree(ov);
+       ov = NULL;
 
 error_out:
        err("Camera initialization failed");
index 685bdae..f69e443 100644 (file)
@@ -868,13 +868,14 @@ static void usb_se401_remove_disconnected (struct usb_se401 *se401)
 
         se401->dev = NULL;
 
-       for (i=0; i<SE401_NUMSBUF; i++) if (se401->urb[i]) {
-               usb_kill_urb(se401->urb[i]);
-               usb_free_urb(se401->urb[i]);
-               se401->urb[i] = NULL;
-               kfree(se401->sbuf[i].data);
-       }
-       for (i=0; i<SE401_NUMSCRATCH; i++) if (se401->scratch[i].data) {
+       for (i=0; i<SE401_NUMSBUF; i++)
+               if (se401->urb[i]) {
+                       usb_kill_urb(se401->urb[i]);
+                       usb_free_urb(se401->urb[i]);
+                       se401->urb[i] = NULL;
+                       kfree(se401->sbuf[i].data);
+               }
+       for (i=0; i<SE401_NUMSCRATCH; i++) {
                kfree(se401->scratch[i].data);
        }
        if (se401->inturb) {
index 298484a..24efb21 100644 (file)
@@ -1169,10 +1169,8 @@ static int usbvideo_v4l_open(struct inode *inode, struct file *file)
                        }
                        RingQueue_Free(&uvd->dp);
                        for (i=0; i < USBVIDEO_NUMSBUF; i++) {
-                               if (uvd->sbuf[i].data != NULL) {
-                                       kfree (uvd->sbuf[i].data);
-                                       uvd->sbuf[i].data = NULL;
-                               }
+                               kfree(uvd->sbuf[i].data);
+                               uvd->sbuf[i].data = NULL;
                        }
                }
        }
index 689e79e..ca9f3a3 100644 (file)
@@ -3624,10 +3624,8 @@ w9968cf_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
        return 0;
 
 fail: /* Free unused memory */
-       if (cam->control_buffer)
-               kfree(cam->control_buffer);
-       if (cam->data_buffer)
-               kfree(cam->data_buffer);
+       kfree(cam->control_buffer);
+       kfree(cam->data_buffer);
        if (cam->v4ldev)
                video_device_release(cam->v4ldev);
        up(&cam->dev_sem);
index a530bb9..6f7994f 100644 (file)
@@ -705,16 +705,12 @@ static int auerchain_control_msg (pauerchain_t acp, struct usb_device *dev, unsi
 /* free a single auerbuf */
 static void auerbuf_free (pauerbuf_t bp)
 {
-       if (bp->bufp) {
-               kfree (bp->bufp);
-       }
-       if (bp->dr) {
-               kfree (bp->dr);
-       }
+       kfree(bp->bufp);
+       kfree(bp->dr);
        if (bp->urbp) {
-               usb_free_urb (bp->urbp);
+               usb_free_urb(bp->urbp);
        }
-       kfree (bp);
+       kfree(bp);
 }
 
 /* free the buffers from an auerbuf list */
@@ -1093,14 +1089,12 @@ exit:
 */
 static void auerswald_int_free (pauerswald_t cp)
 {
-        if (cp->inturbp) {
-                usb_free_urb (cp->inturbp);
-                cp->inturbp = NULL;
-        }
-        if (cp->intbufp) {
-                kfree (cp->intbufp);
-                cp->intbufp = NULL;
-        }
+       if (cp->inturbp) {
+               usb_free_urb(cp->inturbp);
+               cp->inturbp = NULL;
+       }
+       kfree(cp->intbufp);
+       cp->intbufp = NULL;
 }
 
 /* This function is called to activate the interrupt
index 938025e..c81cd0a 100644 (file)
@@ -106,8 +106,7 @@ int zd1201_fw_upload(struct usb_device *dev, int apfw)
 
        err = 0;
 exit:
-       if (buf)
-               kfree(buf);
+       kfree(buf);
        release_firmware(fw_entry);
        return err;
 }
index 86994d1..abb1b2c 100644 (file)
@@ -202,8 +202,7 @@ static void belkin_sa_shutdown (struct usb_serial *serial)
        for (i=0; i < serial->num_ports; ++i) {
                /* My special items, the standard routines free my urbs */
                priv = usb_get_serial_port_data(serial->port[i]);
-               if (priv)
-                       kfree(priv);
+               kfree(priv);
        }
 }
 
index db8f472..d165f42 100644 (file)
@@ -1340,9 +1340,8 @@ static struct cypress_buf *cypress_buf_alloc(unsigned int size)
 
 static void cypress_buf_free(struct cypress_buf *cb)
 {
-       if (cb != NULL) {
-               if (cb->buf_buf != NULL)
-                       kfree(cb->buf_buf);
+       if (cb) {
+               kfree(cb->buf_buf);
                kfree(cb);
        }
 }
index 4d46394..8d562ab 100644 (file)
@@ -550,8 +550,7 @@ failed_usb_register:
 failed_usb_serial_register:
        for (i = 0; i < NUM_URBS; ++i) {
                if (write_urb_pool[i]) {
-                       if (write_urb_pool[i]->transfer_buffer)
-                               kfree(write_urb_pool[i]->transfer_buffer);
+                       kfree(write_urb_pool[i]->transfer_buffer);
                        usb_free_urb(write_urb_pool[i]);
                }
        }
@@ -575,8 +574,7 @@ static void __exit empeg_exit (void)
                         * the host controllers get fixed to set urb->dev = NULL after
                         * the urb is finished.  Otherwise this call oopses. */
                        /* usb_kill_urb(write_urb_pool[i]); */
-                       if (write_urb_pool[i]->transfer_buffer)
-                               kfree(write_urb_pool[i]->transfer_buffer);
+                       kfree(write_urb_pool[i]->transfer_buffer);
                        usb_free_urb (write_urb_pool[i]);
                }
        }
index 4afd905..4c788c7 100644 (file)
@@ -1347,9 +1347,7 @@ static int ftdi_common_startup (struct usb_serial *serial)
        priv->flags = ASYNC_LOW_LATENCY;
 
        /* Increase the size of read buffers */
-       if (port->bulk_in_buffer) {
-               kfree (port->bulk_in_buffer);
-       }
+       kfree(port->bulk_in_buffer);
        port->bulk_in_buffer = kmalloc (BUFSZ, GFP_KERNEL);
        if (!port->bulk_in_buffer) {
                kfree (priv);
@@ -1365,10 +1363,8 @@ static int ftdi_common_startup (struct usb_serial *serial)
                usb_free_urb (port->write_urb);
                port->write_urb = NULL;
        }
-       if (port->bulk_out_buffer) {
-               kfree (port->bulk_out_buffer);
-               port->bulk_out_buffer = NULL;
-       }
+       kfree(port->bulk_out_buffer);
+       port->bulk_out_buffer = NULL;
 
        usb_set_serial_port_data(serial->port[0], priv);
        
index e35b5ad..04bfe27 100644 (file)
@@ -951,9 +951,7 @@ static void edge_bulk_out_cmd_callback (struct urb *urb, struct pt_regs *regs)
 
 
        /* clean up the transfer buffer */
-       if (urb->transfer_buffer != NULL) {
-               kfree(urb->transfer_buffer);
-       }
+       kfree(urb->transfer_buffer);
 
        /* Free the command urb */
        usb_free_urb (urb);
@@ -1266,16 +1264,12 @@ static void edge_close (struct usb_serial_port *port, struct file * filp)
 
        if (edge_port->write_urb) {
                /* if this urb had a transfer buffer already (old transfer) free it */
-               if (edge_port->write_urb->transfer_buffer != NULL) {
-                       kfree(edge_port->write_urb->transfer_buffer);
-               }
-               usb_free_urb   (edge_port->write_urb);
+               kfree(edge_port->write_urb->transfer_buffer);
+               usb_free_urb(edge_port->write_urb);
                edge_port->write_urb = NULL;
        }
-       if (edge_port->txfifo.fifo) {
-               kfree(edge_port->txfifo.fifo);
-               edge_port->txfifo.fifo = NULL;
-       }
+       kfree(edge_port->txfifo.fifo);
+       edge_port->txfifo.fifo = NULL;
 
        dbg("%s exited", __FUNCTION__);
 }   
@@ -1419,11 +1413,9 @@ static void send_more_port_data(struct edgeport_serial *edge_serial, struct edge
        // get a pointer to the write_urb
        urb = edge_port->write_urb;
 
-       /* if this urb had a transfer buffer already (old transfer) free it */
-       if (urb->transfer_buffer != NULL) {
-               kfree(urb->transfer_buffer);
-               urb->transfer_buffer = NULL;
-       }
+       /* make sure transfer buffer is freed */
+       kfree(urb->transfer_buffer);
+       urb->transfer_buffer = NULL;
 
        /* build the data header for the buffer and port that we are about to send out */
        count = fifo->count;
index 6c96fda..ebf9967 100644 (file)
@@ -2845,9 +2845,8 @@ static struct edge_buf *edge_buf_alloc(unsigned int size)
 
 void edge_buf_free(struct edge_buf *eb)
 {
-       if (eb != NULL) {
-               if (eb->buf_buf != NULL)
-                       kfree(eb->buf_buf);
+       if (eb) {
+               kfree(eb->buf_buf);
                kfree(eb);
        }
 }
index 49c602a..a11e829 100644 (file)
@@ -341,8 +341,7 @@ static void klsi_105_shutdown (struct usb_serial *serial)
                                         * finished.  Otherwise this call
                                         * oopses. */
                                        /* usb_kill_urb(write_urbs[j]); */
-                                       if (write_urbs[j]->transfer_buffer)
-                                                   kfree(write_urbs[j]->transfer_buffer);
+                                       kfree(write_urbs[j]->transfer_buffer);
                                        usb_free_urb (write_urbs[j]);
                                }
                        }
index a1cba4b..b5f2c06 100644 (file)
@@ -178,7 +178,6 @@ static void omninet_close (struct usb_serial_port *port, struct file * filp)
 {
        struct usb_serial       *serial = port->serial;
        struct usb_serial_port  *wport;
-       struct omninet_data     *od;
 
        dbg("%s - port %d", __FUNCTION__, port->number);
 
@@ -186,9 +185,7 @@ static void omninet_close (struct usb_serial_port *port, struct file * filp)
        usb_kill_urb(wport->write_urb);
        usb_kill_urb(port->read_urb);
 
-       od = usb_get_serial_port_data(port);
-       if (od)
-               kfree(od);
+       kfree(usb_get_serial_port_data(port));
 }
 
 
index 8e9b007..7eab5d4 100644 (file)
@@ -1044,9 +1044,8 @@ static struct pl2303_buf *pl2303_buf_alloc(unsigned int size)
 
 static void pl2303_buf_free(struct pl2303_buf *pb)
 {
-       if (pb != NULL) {
-               if (pb->buf_buf != NULL)
-                       kfree(pb->buf_buf);
+       if (pb) {
+               kfree(pb->buf_buf);
                kfree(pb);
        }
 }
index 9805487..59c88de 100644 (file)
@@ -517,8 +517,7 @@ static void ti_shutdown(struct usb_serial *serial)
                }
        }
 
-       if (tdev)
-               kfree(tdev);
+       kfree(tdev);
        usb_set_serial_data(serial, NULL);
 }
 
index 229ca18..8451779 100644 (file)
@@ -119,10 +119,8 @@ static int sddr55_status(struct us_data *us)
        /* expect to get short transfer if no card fitted */
        if (result == USB_STOR_XFER_SHORT || result == USB_STOR_XFER_STALLED) {
                /* had a short transfer, no card inserted, free map memory */
-               if (info->lba_to_pba)
-                       kfree(info->lba_to_pba);
-               if (info->pba_to_lba)
-                       kfree(info->pba_to_lba);
+               kfree(info->lba_to_pba);
+               kfree(info->pba_to_lba);
                info->lba_to_pba = NULL;
                info->pba_to_lba = NULL;
 
@@ -649,18 +647,14 @@ static int sddr55_read_map(struct us_data *us) {
                return -1;
        }
 
-       if (info->lba_to_pba)
-               kfree(info->lba_to_pba);
-       if (info->pba_to_lba)
-               kfree(info->pba_to_lba);
+       kfree(info->lba_to_pba);
+       kfree(info->pba_to_lba);
        info->lba_to_pba = kmalloc(numblocks*sizeof(int), GFP_NOIO);
        info->pba_to_lba = kmalloc(numblocks*sizeof(int), GFP_NOIO);
 
        if (info->lba_to_pba == NULL || info->pba_to_lba == NULL) {
-               if (info->lba_to_pba != NULL)
-                       kfree(info->lba_to_pba);
-               if (info->pba_to_lba != NULL)
-                       kfree(info->pba_to_lba);
+               kfree(info->lba_to_pba);
+               kfree(info->pba_to_lba);
                info->lba_to_pba = NULL;
                info->pba_to_lba = NULL;
                kfree(buffer);
@@ -728,10 +722,8 @@ static void sddr55_card_info_destructor(void *extra) {
        if (!extra)
                return;
 
-       if (info->lba_to_pba)
-               kfree(info->lba_to_pba);
-       if (info->pba_to_lba)
-               kfree(info->pba_to_lba);
+       kfree(info->lba_to_pba);
+       kfree(info->pba_to_lba);
 }