Skip to contentSkip to conversation

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

PATCH Applied José Expósito 2 participants 2 messages May 24, 2024 – Jun 4, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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

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()")
---
 drivers/hid/hid-logitech-dj.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/hid/hid-logitech-dj.c +3 -1
index 3c3c497b6b91..37958edec55f 100644
@@ -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;
+		}
 	}
 
 	/*
Signature · 1 line
2.45.1
maintainer Applied
#1 lore raw
Quoted 13 lines · José Expósito

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()")
---
 drivers/hid/hid-logitech-dj.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/hid/hid-logitech-dj.c +0 -0
index 3c3c497b6b91..37958edec55f 100644

drivers/hid/hid-logitech-dj.c static int logi_dj_recv_switch_to_dj_mode(struct dj_receiver_dev *djrcv_dev, · line 1291

Quoted 9 lines
drivers/hid/hid-logitech-dj.c +3 -1
@@ -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.

Signature · 2 lines
Jiri Kosina
SUSE Labs