diff mbox series

HID: logitech-dj: Fix memory leak in logi_dj_recv_switch_to_dj_mode()

Message ID 20240524130600.275577-1-jose.exposito89@gmail.com
State Accepted
Commit ce3af2ee95170b7d9e15fff6e500d67deab1e7b3
Headers show
Series HID: logitech-dj: Fix memory leak in logi_dj_recv_switch_to_dj_mode() | expand

Commit Message

José Expósito May 24, 2024, 1:05 p.m. UTC
Fix a memory leak on logi_dj_recv_send_report() error path.

Fixes: 6f20d3261265 ("HID: logitech-dj: Fix error handling in logi_dj_recv_switch_to_dj_mode()")
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
---
 drivers/hid/hid-logitech-dj.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Jiri Kosina June 4, 2024, 8:16 a.m. UTC | #1
On Fri, 24 May 2024, José Expósito wrote:

> Fix a memory leak on logi_dj_recv_send_report() error path.
> 
> Fixes: 6f20d3261265 ("HID: logitech-dj: Fix error handling in logi_dj_recv_switch_to_dj_mode()")
> Signed-off-by: José Expósito <jose.exposito89@gmail.com>
> ---
>  drivers/hid/hid-logitech-dj.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/hid/hid-logitech-dj.c b/drivers/hid/hid-logitech-dj.c
> index 3c3c497b6b91..37958edec55f 100644
> --- a/drivers/hid/hid-logitech-dj.c
> +++ b/drivers/hid/hid-logitech-dj.c
> @@ -1284,8 +1284,10 @@ static int logi_dj_recv_switch_to_dj_mode(struct dj_receiver_dev *djrcv_dev,
>  		 */
>  		msleep(50);
>  
> -		if (retval)
> +		if (retval) {
> +			kfree(dj_report);
>  			return retval;
> +		}
>  	}

Applied, thanks.
diff mbox series

Patch

diff --git a/drivers/hid/hid-logitech-dj.c b/drivers/hid/hid-logitech-dj.c
index 3c3c497b6b91..37958edec55f 100644
--- a/drivers/hid/hid-logitech-dj.c
+++ b/drivers/hid/hid-logitech-dj.c
@@ -1284,8 +1284,10 @@  static int logi_dj_recv_switch_to_dj_mode(struct dj_receiver_dev *djrcv_dev,
 		 */
 		msleep(50);
 
-		if (retval)
+		if (retval) {
+			kfree(dj_report);
 			return retval;
+		}
 	}
 
 	/*