diff options
author | Julia Lawall <julia@diku.dk> | 2008-07-16 12:00:42 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2008-10-17 17:40:51 -0400 |
commit | 49b707b90c7f7260beb8691fc5d99d71a5549ec0 (patch) | |
tree | 168692010834d1ec378cf8b7810159a7bebf85a8 /drivers/usb/class/usblp.c | |
parent | 5b775f672cc993ba9dba5626811ab1f2ac42883b (diff) |
drivers/usb/class/usblp.c: adjust error handling code
In this code, it is possible to tell statically whether usblp will be NULL
in the error handling code.
Oliver Neukum suggested to make a goto to the final return rather than
return directly.
The semantic match that finds this problem is as follows:
(http://www.emn.fr/x-info/coccinelle/)
// <smpl>
@@
identifier f,err,l,l1;
type T;
expression x,E;
statement S;
@@
x = NULL
... when != goto l1;
* x = f(...)
... when != x
err = E;
goto l;
...
* if (x != NULL)
S
return err;
// </smpl>
Signed-off-by: Julia Lawall <julia@diku.dk>
Cc: Pete Zaitcev <zaitcev@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/class/usblp.c')
-rw-r--r-- | drivers/usb/class/usblp.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c index 0647164d36db..68a2239cd0b6 100644 --- a/drivers/usb/class/usblp.c +++ b/drivers/usb/class/usblp.c | |||
@@ -1076,15 +1076,16 @@ static int usblp_probe(struct usb_interface *intf, | |||
1076 | const struct usb_device_id *id) | 1076 | const struct usb_device_id *id) |
1077 | { | 1077 | { |
1078 | struct usb_device *dev = interface_to_usbdev (intf); | 1078 | struct usb_device *dev = interface_to_usbdev (intf); |
1079 | struct usblp *usblp = NULL; | 1079 | struct usblp *usblp; |
1080 | int protocol; | 1080 | int protocol; |
1081 | int retval; | 1081 | int retval; |
1082 | 1082 | ||
1083 | /* Malloc and start initializing usblp structure so we can use it | 1083 | /* Malloc and start initializing usblp structure so we can use it |
1084 | * directly. */ | 1084 | * directly. */ |
1085 | if (!(usblp = kzalloc(sizeof(struct usblp), GFP_KERNEL))) { | 1085 | usblp = kzalloc(sizeof(struct usblp), GFP_KERNEL); |
1086 | if (!usblp) { | ||
1086 | retval = -ENOMEM; | 1087 | retval = -ENOMEM; |
1087 | goto abort; | 1088 | goto abort_ret; |
1088 | } | 1089 | } |
1089 | usblp->dev = dev; | 1090 | usblp->dev = dev; |
1090 | mutex_init(&usblp->wmut); | 1091 | mutex_init(&usblp->wmut); |
@@ -1179,12 +1180,11 @@ abort_intfdata: | |||
1179 | usb_set_intfdata (intf, NULL); | 1180 | usb_set_intfdata (intf, NULL); |
1180 | device_remove_file(&intf->dev, &dev_attr_ieee1284_id); | 1181 | device_remove_file(&intf->dev, &dev_attr_ieee1284_id); |
1181 | abort: | 1182 | abort: |
1182 | if (usblp) { | 1183 | kfree(usblp->readbuf); |
1183 | kfree(usblp->readbuf); | 1184 | kfree(usblp->statusbuf); |
1184 | kfree(usblp->statusbuf); | 1185 | kfree(usblp->device_id_string); |
1185 | kfree(usblp->device_id_string); | 1186 | kfree(usblp); |
1186 | kfree(usblp); | 1187 | abort_ret: |
1187 | } | ||
1188 | return retval; | 1188 | return retval; |
1189 | } | 1189 | } |
1190 | 1190 | ||