* [patch 2/2] usbhid: fix some error codes in hiddev_connect()
@ 2011-05-26 8:50 Dan Carpenter
2011-05-26 12:07 ` Jiri Kosina
0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2011-05-26 8:50 UTC (permalink / raw)
To: Jiri Kosina
Cc: open list:USB HID/HIDBP DRI..., open list:HID CORE LAYER,
kernel-janitors-u79uwXL29TY76Z2rM5mHXA
Returning -1 is -EPERM which is inappropriate here.
Signed-off-by: Dan Carpenter <error27-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c
index b2f9a3a..80b8e76 100644
--- a/drivers/hid/usbhid/hiddev.c
+++ b/drivers/hid/usbhid/hiddev.c
@@ -890,8 +890,9 @@ int hiddev_connect(struct hid_device *hid, unsigned int force)
return -1;
}
- if (!(hiddev = kzalloc(sizeof(struct hiddev), GFP_KERNEL)))
- return -1;
+ hiddev = kzalloc(sizeof(struct hiddev), GFP_KERNEL);
+ if (!hiddev)
+ return -ENOMEM;
init_waitqueue_head(&hiddev->wait);
INIT_LIST_HEAD(&hiddev->list);
@@ -905,7 +906,7 @@ int hiddev_connect(struct hid_device *hid, unsigned int force)
hid_err(hid, "Not able to get a minor for this device\n");
hid->hiddev = NULL;
kfree(hiddev);
- return -1;
+ return retval;
}
return 0;
}
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [patch 2/2] usbhid: fix some error codes in hiddev_connect()
2011-05-26 8:50 [patch 2/2] usbhid: fix some error codes in hiddev_connect() Dan Carpenter
@ 2011-05-26 12:07 ` Jiri Kosina
2011-05-26 16:35 ` Dan Carpenter
0 siblings, 1 reply; 3+ messages in thread
From: Jiri Kosina @ 2011-05-26 12:07 UTC (permalink / raw)
To: Dan Carpenter
Cc: open list:USB HID/HIDBP DRI..., open list:HID CORE LAYER,
kernel-janitors
On Thu, 26 May 2011, Dan Carpenter wrote:
> Returning -1 is -EPERM which is inappropriate here.
>
> Signed-off-by: Dan Carpenter <error27@gmail.com>
>
> diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c
> index b2f9a3a..80b8e76 100644
> --- a/drivers/hid/usbhid/hiddev.c
> +++ b/drivers/hid/usbhid/hiddev.c
> @@ -890,8 +890,9 @@ int hiddev_connect(struct hid_device *hid, unsigned int force)
> return -1;
> }
>
> - if (!(hiddev = kzalloc(sizeof(struct hiddev), GFP_KERNEL)))
> - return -1;
> + hiddev = kzalloc(sizeof(struct hiddev), GFP_KERNEL);
> + if (!hiddev)
> + return -ENOMEM;
>
> init_waitqueue_head(&hiddev->wait);
> INIT_LIST_HEAD(&hiddev->list);
> @@ -905,7 +906,7 @@ int hiddev_connect(struct hid_device *hid, unsigned int force)
> hid_err(hid, "Not able to get a minor for this device\n");
> hid->hiddev = NULL;
> kfree(hiddev);
> - return -1;
> + return retval;
> }
> return 0;
> }
Why would that matter?
hid_connect() (which is the only caller) only checks for the return value
being (non-)zero.
--
Jiri Kosina
SUSE Labs
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch 2/2] usbhid: fix some error codes in hiddev_connect()
2011-05-26 12:07 ` Jiri Kosina
@ 2011-05-26 16:35 ` Dan Carpenter
0 siblings, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2011-05-26 16:35 UTC (permalink / raw)
To: Jiri Kosina
Cc: open list:USB HID/HIDBP DRI..., open list:HID CORE LAYER,
kernel-janitors
On Thu, May 26, 2011 at 02:07:00PM +0200, Jiri Kosina wrote:
> Why would that matter?
>
> hid_connect() (which is the only caller) only checks for the return value
> being (non-)zero.
It's just a cleanup. It silences a Smatch complaint.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-05-26 16:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-26 8:50 [patch 2/2] usbhid: fix some error codes in hiddev_connect() Dan Carpenter
2011-05-26 12:07 ` Jiri Kosina
2011-05-26 16:35 ` Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).