All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hid: hid-nintendo: check the return value of alloc_workqueue()
@ 2022-02-25  3:41 Jia-Ju Bai
  2022-02-26 14:14 ` Silvan Jegen
  2022-03-01 14:58 ` Jiri Kosina
  0 siblings, 2 replies; 3+ messages in thread
From: Jia-Ju Bai @ 2022-02-25  3:41 UTC (permalink / raw)
  To: djogorchock, jikos, benjamin.tissoires
  Cc: linux-input, linux-kernel, Jia-Ju Bai

The function alloc_workqueue() in nintendo_hid_probe() can fail, but
there is no check of its return value. To fix this bug, its return value
should be checked with new error handling code.

Fixes: c4eae84feff3e ("HID: nintendo: add rumble support")
Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
---
 drivers/hid/hid-nintendo.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/hid/hid-nintendo.c b/drivers/hid/hid-nintendo.c
index b6a9a0f3966e..2204de889739 100644
--- a/drivers/hid/hid-nintendo.c
+++ b/drivers/hid/hid-nintendo.c
@@ -2128,6 +2128,10 @@ static int nintendo_hid_probe(struct hid_device *hdev,
 	spin_lock_init(&ctlr->lock);
 	ctlr->rumble_queue = alloc_workqueue("hid-nintendo-rumble_wq",
 					     WQ_FREEZABLE | WQ_MEM_RECLAIM, 0);
+	if (!ctlr->rumble_queue) {
+		ret = -ENOMEM;
+		goto err;
+	}
 	INIT_WORK(&ctlr->rumble_worker, joycon_rumble_worker);
 
 	ret = hid_parse(hdev);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] hid: hid-nintendo: check the return value of alloc_workqueue()
  2022-02-25  3:41 [PATCH] hid: hid-nintendo: check the return value of alloc_workqueue() Jia-Ju Bai
@ 2022-02-26 14:14 ` Silvan Jegen
  2022-03-01 14:58 ` Jiri Kosina
  1 sibling, 0 replies; 3+ messages in thread
From: Silvan Jegen @ 2022-02-26 14:14 UTC (permalink / raw)
  To: Jia-Ju Bai
  Cc: djogorchock, jikos, benjamin.tissoires, linux-input, linux-kernel

Hi

Jia-Ju Bai <baijiaju1990@gmail.com> wrote:
> The function alloc_workqueue() in nintendo_hid_probe() can fail, but
> there is no check of its return value. To fix this bug, its return value
> should be checked with new error handling code.
> 
> Fixes: c4eae84feff3e ("HID: nintendo: add rumble support")
> Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
> Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
> ---
>  drivers/hid/hid-nintendo.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/hid/hid-nintendo.c b/drivers/hid/hid-nintendo.c
> index b6a9a0f3966e..2204de889739 100644
> --- a/drivers/hid/hid-nintendo.c
> +++ b/drivers/hid/hid-nintendo.c
> @@ -2128,6 +2128,10 @@ static int nintendo_hid_probe(struct hid_device *hdev,
>  	spin_lock_init(&ctlr->lock);
>  	ctlr->rumble_queue = alloc_workqueue("hid-nintendo-rumble_wq",
>  					     WQ_FREEZABLE | WQ_MEM_RECLAIM, 0);
> +	if (!ctlr->rumble_queue) {
> +		ret = -ENOMEM;
> +		goto err;
> +	}
>  	INIT_WORK(&ctlr->rumble_worker, joycon_rumble_worker);
>  
>  	ret = hid_parse(hdev);

LGTM!

Reviewed-by: Silvan Jegen <s.jegen@gmail.com>


Cheers,

Silvan

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] hid: hid-nintendo: check the return value of alloc_workqueue()
  2022-02-25  3:41 [PATCH] hid: hid-nintendo: check the return value of alloc_workqueue() Jia-Ju Bai
  2022-02-26 14:14 ` Silvan Jegen
@ 2022-03-01 14:58 ` Jiri Kosina
  1 sibling, 0 replies; 3+ messages in thread
From: Jiri Kosina @ 2022-03-01 14:58 UTC (permalink / raw)
  To: Jia-Ju Bai; +Cc: djogorchock, benjamin.tissoires, linux-input, linux-kernel

On Thu, 24 Feb 2022, Jia-Ju Bai wrote:

> The function alloc_workqueue() in nintendo_hid_probe() can fail, but
> there is no check of its return value. To fix this bug, its return value
> should be checked with new error handling code.
> 
> Fixes: c4eae84feff3e ("HID: nintendo: add rumble support")
> Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
> Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
> ---
>  drivers/hid/hid-nintendo.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/hid/hid-nintendo.c b/drivers/hid/hid-nintendo.c
> index b6a9a0f3966e..2204de889739 100644
> --- a/drivers/hid/hid-nintendo.c
> +++ b/drivers/hid/hid-nintendo.c
> @@ -2128,6 +2128,10 @@ static int nintendo_hid_probe(struct hid_device *hdev,
>  	spin_lock_init(&ctlr->lock);
>  	ctlr->rumble_queue = alloc_workqueue("hid-nintendo-rumble_wq",
>  					     WQ_FREEZABLE | WQ_MEM_RECLAIM, 0);
> +	if (!ctlr->rumble_queue) {
> +		ret = -ENOMEM;
> +		goto err;
> +	}
>  	INIT_WORK(&ctlr->rumble_worker, joycon_rumble_worker);

Thanks for the patch.

For future submissions, please try to make sure to always follow the 
subsystem-specific formatting of the shortlog (upperacase "HID: " prefix 
in this case).

I've fixed that up and applied.

-- 
Jiri Kosina
SUSE Labs


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-03-01 14:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-25  3:41 [PATCH] hid: hid-nintendo: check the return value of alloc_workqueue() Jia-Ju Bai
2022-02-26 14:14 ` Silvan Jegen
2022-03-01 14:58 ` Jiri Kosina

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.