Skip to contentSkip to conversation

input: raspberrypi-ts: Fix refcount leak in rpi_ts_probe

PATCH Applied Miaoqian Lin 3 participants 3 messages Dec 23, 2022 – Apr 14, 2023

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

PATCH v2 1/1 input: raspberrypi-ts: Fix refcount leak in rpi_ts_probe

rpi_firmware_get() take reference, we need to release it in error paths as well. Use devm_rpi_firmware_get() helper to handling the resources. Also remove the existing rpi_firmware_put().

Fixes 0b9f28fed3f7 ("Input: add official Raspberry Pi's touchscreen driver")
Fixes 3b8ddff780b7 ("input: raspberrypi-ts: Release firmware handle when not needed")

---
changes in v2:
- use devm_rpi_firmware_get().
- remove rpi_firmware_put().

---
 drivers/input/touchscreen/raspberrypi-ts.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/input/touchscreen/raspberrypi-ts.c +1 -2
index 5000f5fd9ec3..45c575df994e 100644
@@ -134,7 +134,7 @@ static int rpi_ts_probe(struct platform_device *pdev)
 		return -ENOENT;
 	}
 
-	fw = rpi_firmware_get(fw_node);
+	fw = devm_rpi_firmware_get(&pdev->dev, fw_node);
 	of_node_put(fw_node);
 	if (!fw)
 		return -EPROBE_DEFER;
@@ -160,7 +160,6 @@ static int rpi_ts_probe(struct platform_device *pdev)
 	touchbuf = (u32)ts->fw_regs_phys;
 	error = rpi_firmware_property(fw, RPI_FIRMWARE_FRAMEBUFFER_SET_TOUCHBUF,
 				      &touchbuf, sizeof(touchbuf));
-	rpi_firmware_put(fw);
 	if (error || touchbuf != 0) {
 		dev_warn(dev, "Failed to set touchbuf, %d\n", error);
 		return error;
Signature · 1 line
2.25.1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 11 lines · Miaoqian Lin

rpi_firmware_get() take reference, we need to release it in error paths as well. Use devm_rpi_firmware_get() helper to handling the resources. Also remove the existing rpi_firmware_put().

Fixes 0b9f28fed3f7 ("Input: add official Raspberry Pi's touchscreen driver")
Fixes 3b8ddff780b7 ("input: raspberrypi-ts: Release firmware handle when not needed")

---
changes in v2:
- use devm_rpi_firmware_get().
- remove rpi_firmware_put().

Quoted 27 lines
---
 drivers/input/touchscreen/raspberrypi-ts.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/input/touchscreen/raspberrypi-ts.c +1 -2
index 5000f5fd9ec3..45c575df994e 100644
@@ -134,7 +134,7 @@ static int rpi_ts_probe(struct platform_device *pdev)
 		return -ENOENT;
 	}
 
-	fw = rpi_firmware_get(fw_node);
+	fw = devm_rpi_firmware_get(&pdev->dev, fw_node);
 	of_node_put(fw_node);
 	if (!fw)
 		return -EPROBE_DEFER;
@@ -160,7 +160,6 @@ static int rpi_ts_probe(struct platform_device *pdev)
 	touchbuf = (u32)ts->fw_regs_phys;
 	error = rpi_firmware_property(fw, RPI_FIRMWARE_FRAMEBUFFER_SET_TOUCHBUF,
 				      &touchbuf, sizeof(touchbuf));
-	rpi_firmware_put(fw);
 	if (error || touchbuf != 0) {
 		dev_warn(dev, "Failed to set touchbuf, %d\n", error);
 		return error;
Signature · 1 line
2.25.1
maintainer Applied
#2 lore raw
In reply to Miaoqian Lin
Quoted 7 lines · Miaoqian Lin

rpi_firmware_get() take reference, we need to release it in error paths as well. Use devm_rpi_firmware_get() helper to handling the resources. Also remove the existing rpi_firmware_put().

Fixes 0b9f28fed3f7 ("Input: add official Raspberry Pi's touchscreen driver")
Fixes 3b8ddff780b7 ("input: raspberrypi-ts: Release firmware handle when not needed")

Applied, thank you.

Signature · 1 line
Dmitry