serial: core: fix OF node leak
PATCH 1/1 serial: core: fix OF node leak
Make sure to drop the OF node reference taken when initialising the control and port devices when the devices are later released.
--- drivers/tty/serial/serial_base_bus.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/tty/serial/serial_base_bus.c +3 -0
@@ -13,6 +13,7 @@#include <linux/device.h> #include <linux/idr.h> #include <linux/module.h> +#include <linux/of.h> #include <linux/serial_core.h> #include <linux/slab.h> #include <linux/spinlock.h>
@@ -93,6 +94,7 @@ static void serial_base_ctrl_release(struct device *dev) {struct serial_ctrl_device *ctrl_dev =to_serial_base_ctrl_device (dev); +of_node_put (dev->of_node);kfree (ctrl_dev); }
@@ -140,6 +142,7 @@ static void serial_base_port_release(struct device *dev) {struct serial_port_device *port_dev =to_serial_base_port_device (dev); +of_node_put (dev->of_node);kfree (port_dev); }
Signature · 1 line
2.49.0
Hi Johan,
Quoted 48 lines · Johan Hovold
CAUTION: This email originated from outside the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.
Make sure to drop the OF node reference taken when initialising the control and port devices when the devices are later released.
Fixes d36f0e9a0002 ("serial: core: restore of_node information insysfs")
Cc Aidan Stewart <[email protected]>Signed-off-by Johan Hovold <[email protected]>---
drivers/tty/serial/serial_base_bus.c | 3 +++1 file changed, 3 insertions(+)drivers/tty/serial/serial_base_bus.c +1
-0@@ -13,6 +13,7 @@ #include <linux/device.h> #include <linux/idr.h> #include <linux/module.h> +#include <linux/of.h> #include <linux/serial_core.h> #include <linux/slab.h> #include <linux/spinlock.h>@@ -93,6 +94,7 @@ static void serial_base_ctrl_release(struct device *dev) {struct
serial_ctrl_device*ctrl_dev=to_serial_base_ctrl_device(dev);+
of_node_put(dev->of_node);
kfree(ctrl_dev);
}drivers/tty/serial/serial_base_bus.c +0
-0@@ -140,6 +142,7 @@ static void serial_base_port_release(struct device *dev) {struct
serial_port_device*port_dev=to_serial_base_port_device(dev);
Quoted 6 lines
+
of_node_put(dev->of_node);
kfree(port_dev);
}--
2.49.0
Thanks for the fix. I think this also needs to go into -stable, as the previous changes have already landed there (6.12.36 and 6.15.5).
Aidan
Quoted 5 lines · Aidan Stewart
Quoted 3 lines · Johan Hovold
Make sure to drop the OF node reference taken when initialising the control and port devices when the devices are later released.
Quoted 7 lines
Quoted 4 lines
Fixes d36f0e9a0002 ("serial: core: restore of_node information insysfs")
Cc Aidan Stewart <[email protected]>Signed-off-by Johan Hovold <[email protected]>Thanks for the fix. I think this also needs to go into -stable, as the previous changes have already landed there (6.12.36 and 6.15.5).
I left out the stable tag on purpose since this leak should not cause trouble as, for example, these devices are typically registered at boot and never deregistered.
It fixes an issue introduced in rc4 so it should preferably still go into 6.16-final, though.
Johan
Greg Kroah-Hartman
maintainerQuoted 14 lines · Johan Hovold
Quoted 5 lines · Aidan Stewart
Quoted 3 lines · Johan Hovold
Make sure to drop the OF node reference taken when initialising the control and port devices when the devices are later released.
Quoted 7 lines
Quoted 4 lines
Fixes d36f0e9a0002 ("serial: core: restore of_node information insysfs")
Cc Aidan Stewart <[email protected]>Signed-off-by Johan Hovold <[email protected]>Thanks for the fix. I think this also needs to go into -stable, as the previous changes have already landed there (6.12.36 and 6.15.5).
Quoted 6 lines
I left out the stable tag on purpose since this leak should not cause trouble as, for example, these devices are typically registered at boot and never deregistered.
It fixes an issue introduced in rc4 so it should preferably still go into 6.16-final, though.
Ok, will get this merged, thanks!
greg k-h