Skip to contentSkip to conversation

gpiolib: cdev: Fix resource leaks on errors in lineinfo_changed_notify()

PATCH Applied Tzung-Bi Shih 2 participants 2 messages Jan 20

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

PATCH v2 1/1 gpiolib: cdev: Fix resource leaks on errors in lineinfo_changed_notify()

On error handling paths, lineinfo_changed_notify() doesn't free the allocated resources which results leaks. Fix it.

Fixes d4cd0902c156 ("gpio: cdev: make sure the cdev fd is still active before emitting events")

---
v2:
- Drop the label "err_put_fp" and fput() in the error path directly.
- Add "cdev" prefix in title.

v1: https://lore.kernel.org/all/[email protected]/

 drivers/gpio/gpiolib-cdev.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpio/gpiolib-cdev.c +1 -0
index 550795987da0..b886f4474e5a 100644
@@ -2549,6 +2549,7 @@ static int lineinfo_changed_notify(struct notifier_block *nb,
 	ctx = kzalloc(sizeof(*ctx), GFP_ATOMIC);
 	if (!ctx) {
 		pr_err("Failed to allocate memory for line info notification\n");
+		fput(fp);
 		return NOTIFY_DONE;
 	}
 
Signature · 1 line
2.52.0.457.g6b5491de43-goog
#1 lore raw
Quoted 4 lines · Tzung-Bi Shih

On error handling paths, lineinfo_changed_notify() doesn't free the allocated resources which results leaks. Fix it.

Applied, thanks!

[1/1] gpiolib: cdev: Fix resource leaks on errors in lineinfo_changed_notify()

      commit: 70b3c280533167749a8f740acaa8ef720f78f984

Best regards,

Signature · 1 line
Bartosz Golaszewski <[email protected]>