Message ID | 20250105111050.3859712-1-joe@pf.is.s.u-tokyo.ac.jp (mailing list archive) |
---|---|
State | New |
Delegated to: | Kieran Bingham |
Headers | show |
Series | media: rcar_drif: Fix an OF node leak in rcar_drif_bond_enabled() | expand |
On Sun, Jan 5, 2025 at 12:11 PM Joe Hattori <joe@pf.is.s.u-tokyo.ac.jp> wrote: > rcar_drif_bond_enabled() leaks an OF node reference when the > of_parse_phandle() returns a node and of_device_is_available() is false. > Add a of_node_put() call before returning NULL. > > This was found by an experimental verifier that I am developing. Due to > the lack of the actual device, no runtime test was able to be performed. > > Fixes: 7625ee981af1 ("[media] media: platform: rcar_drif: Add DRIF support") > Signed-off-by: Joe Hattori <joe@pf.is.s.u-tokyo.ac.jp> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Gr{oetje,eeting}s, Geert
> From: Joe Hattori <joe@pf.is.s.u-tokyo.ac.jp> > Sent: 05 January 2025 11:11 > To: Fabrizio Castro <fabrizio.castro.jz@renesas.com>; mchehab@kernel.org > Cc: linux-renesas-soc@vger.kernel.org; Joe Hattori <joe@pf.is.s.u-tokyo.ac.jp> > Subject: [PATCH] media: rcar_drif: Fix an OF node leak in rcar_drif_bond_enabled() > > rcar_drif_bond_enabled() leaks an OF node reference when the > of_parse_phandle() returns a node and of_device_is_available() is false. > Add a of_node_put() call before returning NULL. > > This was found by an experimental verifier that I am developing. Due to > the lack of the actual device, no runtime test was able to be performed. > > Fixes: 7625ee981af1 ("[media] media: platform: rcar_drif: Add DRIF support") > Signed-off-by: Joe Hattori <joe@pf.is.s.u-tokyo.ac.jp> Reviewed-by: Fabrizio Castro <fabrizio.castro.jz@renesas.com> Cheers, Fab > --- > drivers/media/platform/renesas/rcar_drif.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/media/platform/renesas/rcar_drif.c b/drivers/media/platform/renesas/rcar_drif.c > index fc8b6bbef793..c5d676eb1091 100644 > --- a/drivers/media/platform/renesas/rcar_drif.c > +++ b/drivers/media/platform/renesas/rcar_drif.c > @@ -1246,6 +1246,7 @@ static struct device_node *rcar_drif_bond_enabled(struct platform_device *p) > if (np && of_device_is_available(np)) > return np; > > + of_node_put(np); > return NULL; > } > > -- > 2.34.1
diff --git a/drivers/media/platform/renesas/rcar_drif.c b/drivers/media/platform/renesas/rcar_drif.c index fc8b6bbef793..c5d676eb1091 100644 --- a/drivers/media/platform/renesas/rcar_drif.c +++ b/drivers/media/platform/renesas/rcar_drif.c @@ -1246,6 +1246,7 @@ static struct device_node *rcar_drif_bond_enabled(struct platform_device *p) if (np && of_device_is_available(np)) return np; + of_node_put(np); return NULL; }
rcar_drif_bond_enabled() leaks an OF node reference when the of_parse_phandle() returns a node and of_device_is_available() is false. Add a of_node_put() call before returning NULL. This was found by an experimental verifier that I am developing. Due to the lack of the actual device, no runtime test was able to be performed. Fixes: 7625ee981af1 ("[media] media: platform: rcar_drif: Add DRIF support") Signed-off-by: Joe Hattori <joe@pf.is.s.u-tokyo.ac.jp> --- drivers/media/platform/renesas/rcar_drif.c | 1 + 1 file changed, 1 insertion(+)