Linux Input Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] HID: alps: Fix an error handling path in 'alps_input_configured()'
@ 2019-12-04  3:35 Christophe JAILLET
  2020-02-12 14:06 ` Jiri Kosina
  0 siblings, 1 reply; 2+ messages in thread
From: Christophe JAILLET @ 2019-12-04  3:35 UTC (permalink / raw)
  To: jkosina, benjamin.tissoires, masaki.ota
  Cc: linux-input, linux-kernel, kernel-janitors, Christophe JAILLET

They are issues:
   - if 'input_allocate_device()' fails and return NULL, there is no need
     to free anything and 'input_free_device()' call is a no-op. It can
     be axed.
   - 'ret' is known to be 0 at this point, so we must set it to a
     meaningful value before returning

Fixes: 2562756dde55 ("HID: add Alps I2C HID Touchpad-Stick support")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/hid/hid-alps.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hid/hid-alps.c b/drivers/hid/hid-alps.c
index ae79a7c66737..fa704153cb00 100644
--- a/drivers/hid/hid-alps.c
+++ b/drivers/hid/hid-alps.c
@@ -730,7 +730,7 @@ static int alps_input_configured(struct hid_device *hdev, struct hid_input *hi)
 	if (data->has_sp) {
 		input2 = input_allocate_device();
 		if (!input2) {
-			input_free_device(input2);
+			ret = -ENOMEM;
 			goto exit;
 		}
 
-- 
2.20.1


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

* Re: [PATCH] HID: alps: Fix an error handling path in 'alps_input_configured()'
  2019-12-04  3:35 [PATCH] HID: alps: Fix an error handling path in 'alps_input_configured()' Christophe JAILLET
@ 2020-02-12 14:06 ` Jiri Kosina
  0 siblings, 0 replies; 2+ messages in thread
From: Jiri Kosina @ 2020-02-12 14:06 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: benjamin.tissoires, masaki.ota, linux-input, linux-kernel,
	kernel-janitors

On Wed, 4 Dec 2019, Christophe JAILLET wrote:

> They are issues:
>    - if 'input_allocate_device()' fails and return NULL, there is no need
>      to free anything and 'input_free_device()' call is a no-op. It can
>      be axed.
>    - 'ret' is known to be 0 at this point, so we must set it to a
>      meaningful value before returning
> 
> Fixes: 2562756dde55 ("HID: add Alps I2C HID Touchpad-Stick support")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
>  drivers/hid/hid-alps.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/hid/hid-alps.c b/drivers/hid/hid-alps.c
> index ae79a7c66737..fa704153cb00 100644
> --- a/drivers/hid/hid-alps.c
> +++ b/drivers/hid/hid-alps.c
> @@ -730,7 +730,7 @@ static int alps_input_configured(struct hid_device *hdev, struct hid_input *hi)
>  	if (data->has_sp) {
>  		input2 = input_allocate_device();
>  		if (!input2) {
> -			input_free_device(input2);
> +			ret = -ENOMEM;
>  			goto exit;
>  		}

Applied, thank you.

-- 
Jiri Kosina
SUSE Labs


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

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-04  3:35 [PATCH] HID: alps: Fix an error handling path in 'alps_input_configured()' Christophe JAILLET
2020-02-12 14:06 ` Jiri Kosina

Linux Input Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-input/0 linux-input/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-input linux-input/ https://lore.kernel.org/linux-input \
		linux-input@vger.kernel.org
	public-inbox-index linux-input

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-input


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git