diff options
author | Jesper Juhl <juhl-lkml@dif.dk> | 2005-04-18 20:39:33 -0400 |
---|---|---|
committer | Greg K-H <gregkh@suse.de> | 2005-04-18 20:39:33 -0400 |
commit | 6fd19f4b55f7fd1c9d8650bd7f8df2c81b69c5ca (patch) | |
tree | 273f17ca46a177cc9c33d3022dfb1528c3d542b9 | |
parent | acbb36f116243bed515357264ecbb6ff9c6d2a5b (diff) |
[PATCH] usb: kfree() cleanups in drivers/usb/core/devio.c
Checking for NULL before calling kfree() is redundant. This patch removes
these redundant checks and also makes a few tiny whitespace changes.
Signed-off-by: Jesper Juhl <juhl-lkml@dif.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/usb/core/devio.c | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c index 923e5185c036..6bfab4bcaa9e 100644 --- a/drivers/usb/core/devio.c +++ b/drivers/usb/core/devio.c | |||
@@ -213,12 +213,10 @@ static struct async *alloc_async(unsigned int numisoframes) | |||
213 | 213 | ||
214 | static void free_async(struct async *as) | 214 | static void free_async(struct async *as) |
215 | { | 215 | { |
216 | if (as->urb->transfer_buffer) | 216 | kfree(as->urb->transfer_buffer); |
217 | kfree(as->urb->transfer_buffer); | 217 | kfree(as->urb->setup_packet); |
218 | if (as->urb->setup_packet) | ||
219 | kfree(as->urb->setup_packet); | ||
220 | usb_free_urb(as->urb); | 218 | usb_free_urb(as->urb); |
221 | kfree(as); | 219 | kfree(as); |
222 | } | 220 | } |
223 | 221 | ||
224 | static inline void async_newpending(struct async *as) | 222 | static inline void async_newpending(struct async *as) |
@@ -938,17 +936,13 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, | |||
938 | return -EINVAL; | 936 | return -EINVAL; |
939 | } | 937 | } |
940 | if (!(as = alloc_async(uurb->number_of_packets))) { | 938 | if (!(as = alloc_async(uurb->number_of_packets))) { |
941 | if (isopkt) | 939 | kfree(isopkt); |
942 | kfree(isopkt); | 940 | kfree(dr); |
943 | if (dr) | ||
944 | kfree(dr); | ||
945 | return -ENOMEM; | 941 | return -ENOMEM; |
946 | } | 942 | } |
947 | if (!(as->urb->transfer_buffer = kmalloc(uurb->buffer_length, GFP_KERNEL))) { | 943 | if (!(as->urb->transfer_buffer = kmalloc(uurb->buffer_length, GFP_KERNEL))) { |
948 | if (isopkt) | 944 | kfree(isopkt); |
949 | kfree(isopkt); | 945 | kfree(dr); |
950 | if (dr) | ||
951 | kfree(dr); | ||
952 | free_async(as); | 946 | free_async(as); |
953 | return -ENOMEM; | 947 | return -ENOMEM; |
954 | } | 948 | } |
@@ -967,8 +961,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, | |||
967 | as->urb->iso_frame_desc[u].length = isopkt[u].length; | 961 | as->urb->iso_frame_desc[u].length = isopkt[u].length; |
968 | totlen += isopkt[u].length; | 962 | totlen += isopkt[u].length; |
969 | } | 963 | } |
970 | if (isopkt) | 964 | kfree(isopkt); |
971 | kfree(isopkt); | ||
972 | as->ps = ps; | 965 | as->ps = ps; |
973 | as->userurb = arg; | 966 | as->userurb = arg; |
974 | if (uurb->endpoint & USB_DIR_IN) | 967 | if (uurb->endpoint & USB_DIR_IN) |
@@ -1237,7 +1230,7 @@ static int proc_ioctl (struct dev_state *ps, void __user *arg) | |||
1237 | return -ENOMEM; | 1230 | return -ENOMEM; |
1238 | if ((_IOC_DIR(ctrl.ioctl_code) & _IOC_WRITE)) { | 1231 | if ((_IOC_DIR(ctrl.ioctl_code) & _IOC_WRITE)) { |
1239 | if (copy_from_user (buf, ctrl.data, size)) { | 1232 | if (copy_from_user (buf, ctrl.data, size)) { |
1240 | kfree (buf); | 1233 | kfree(buf); |
1241 | return -EFAULT; | 1234 | return -EFAULT; |
1242 | } | 1235 | } |
1243 | } else { | 1236 | } else { |
@@ -1246,8 +1239,7 @@ static int proc_ioctl (struct dev_state *ps, void __user *arg) | |||
1246 | } | 1239 | } |
1247 | 1240 | ||
1248 | if (!connected(ps->dev)) { | 1241 | if (!connected(ps->dev)) { |
1249 | if (buf) | 1242 | kfree(buf); |
1250 | kfree(buf); | ||
1251 | return -ENODEV; | 1243 | return -ENODEV; |
1252 | } | 1244 | } |
1253 | 1245 | ||
@@ -1309,8 +1301,8 @@ static int proc_ioctl (struct dev_state *ps, void __user *arg) | |||
1309 | && size > 0 | 1301 | && size > 0 |
1310 | && copy_to_user (ctrl.data, buf, size) != 0) | 1302 | && copy_to_user (ctrl.data, buf, size) != 0) |
1311 | retval = -EFAULT; | 1303 | retval = -EFAULT; |
1312 | if (buf != NULL) | 1304 | |
1313 | kfree (buf); | 1305 | kfree(buf); |
1314 | return retval; | 1306 | return retval; |
1315 | } | 1307 | } |
1316 | 1308 | ||