All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] HID: alps: Fix memory leak
@ 2016-09-11  4:09 Axel Lin
  2016-09-14  8:35 ` Benjamin Tissoires
  2016-09-19 12:43 ` Jiri Kosina
  0 siblings, 2 replies; 3+ messages in thread
From: Axel Lin @ 2016-09-11  4:09 UTC (permalink / raw)
  To: Jiri Kosina; +Cc: Masaki Ota, Benjamin Tissoires, linux-input, Axel Lin

A kfree(readbuf) call was missed if hid_hw_raw_request() fails, fix it.
Also avoid mixing direct return with goto in the error paths.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
 drivers/hid/hid-alps.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/hid/hid-alps.c b/drivers/hid/hid-alps.c
index 048befd..2808da9 100644
--- a/drivers/hid/hid-alps.c
+++ b/drivers/hid/hid-alps.c
@@ -139,8 +139,8 @@ static int u1_read_write_register(struct hid_device *hdev, u32 address,
 	if (read_flag) {
 		readbuf = kzalloc(U1_FEATURE_REPORT_LEN, GFP_KERNEL);
 		if (!readbuf) {
-			kfree(input);
-			return -ENOMEM;
+			ret = -ENOMEM;
+			goto exit;
 		}
 
 		ret = hid_hw_raw_request(hdev, U1_FEATURE_REPORT_ID, readbuf,
@@ -149,6 +149,7 @@ static int u1_read_write_register(struct hid_device *hdev, u32 address,
 
 		if (ret < 0) {
 			dev_err(&hdev->dev, "failed read register (%d)\n", ret);
+			kfree(readbuf);
 			goto exit;
 		}
 
-- 
2.7.4


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

* Re: [PATCH] HID: alps: Fix memory leak
  2016-09-11  4:09 [PATCH] HID: alps: Fix memory leak Axel Lin
@ 2016-09-14  8:35 ` Benjamin Tissoires
  2016-09-19 12:43 ` Jiri Kosina
  1 sibling, 0 replies; 3+ messages in thread
From: Benjamin Tissoires @ 2016-09-14  8:35 UTC (permalink / raw)
  To: Axel Lin; +Cc: Jiri Kosina, Masaki Ota, linux-input

On Sep 11 2016 or thereabouts, Axel Lin wrote:
> A kfree(readbuf) call was missed if hid_hw_raw_request() fails, fix it.
> Also avoid mixing direct return with goto in the error paths.
> 
> Signed-off-by: Axel Lin <axel.lin@ingics.com>

Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>

Cheers,
Benjamin

> ---
>  drivers/hid/hid-alps.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/hid/hid-alps.c b/drivers/hid/hid-alps.c
> index 048befd..2808da9 100644
> --- a/drivers/hid/hid-alps.c
> +++ b/drivers/hid/hid-alps.c
> @@ -139,8 +139,8 @@ static int u1_read_write_register(struct hid_device *hdev, u32 address,
>  	if (read_flag) {
>  		readbuf = kzalloc(U1_FEATURE_REPORT_LEN, GFP_KERNEL);
>  		if (!readbuf) {
> -			kfree(input);
> -			return -ENOMEM;
> +			ret = -ENOMEM;
> +			goto exit;
>  		}
>  
>  		ret = hid_hw_raw_request(hdev, U1_FEATURE_REPORT_ID, readbuf,
> @@ -149,6 +149,7 @@ static int u1_read_write_register(struct hid_device *hdev, u32 address,
>  
>  		if (ret < 0) {
>  			dev_err(&hdev->dev, "failed read register (%d)\n", ret);
> +			kfree(readbuf);
>  			goto exit;
>  		}
>  
> -- 
> 2.7.4
> 

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

* Re: [PATCH] HID: alps: Fix memory leak
  2016-09-11  4:09 [PATCH] HID: alps: Fix memory leak Axel Lin
  2016-09-14  8:35 ` Benjamin Tissoires
@ 2016-09-19 12:43 ` Jiri Kosina
  1 sibling, 0 replies; 3+ messages in thread
From: Jiri Kosina @ 2016-09-19 12:43 UTC (permalink / raw)
  To: Axel Lin; +Cc: Masaki Ota, Benjamin Tissoires, linux-input

On Sun, 11 Sep 2016, Axel Lin wrote:

> A kfree(readbuf) call was missed if hid_hw_raw_request() fails, fix it.
> Also avoid mixing direct return with goto in the error paths.

Applied to hid.git#for-4.8/upstream-fixes, thanks.

-- 
Jiri Kosina
SUSE Labs


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

end of thread, other threads:[~2016-09-19 12:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-11  4:09 [PATCH] HID: alps: Fix memory leak Axel Lin
2016-09-14  8:35 ` Benjamin Tissoires
2016-09-19 12:43 ` 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.