Message ID | 55928739.5040809@users.sourceforge.net (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Hello Markus On Tue, 30 Jun 2015, SF Markus Elfring wrote: > From: Markus Elfring <elfring@users.sourceforge.net> > Date: Tue, 30 Jun 2015 14:00:16 +0200 > > The functions clk_disable(), of_node_put() and omap_device_delete() test > whether their argument is NULL and then return immediately. > Thus the test around the call is not needed. > > This issue was detected by using the Coccinelle software. > > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> Thanks for the patch. I have to say, I am a bit leery about applying the omap_device.c and omap_hwmod.c changes, since the called functions -- omap_device_delete() and clk_disable() -- don't explicitly document that NULLs are allowed to be passed in. So there's no explicit contract that callers can rely upon, to (at least in theory) prevent those internal NULL pointer checks from being removed. So I would suggest that those two functions' kerneldoc be patched first to explicitly state that passing in a NULL pointer is allowed. Then I would feel a bit more comfortable applying the omap_device.c and omap_hwmod.c changes. The kerneldoc for of_node_put() does explicitly allow NULLs to be passed in. So I'll apply that change now for v4.3, touching up the commit message accordingly. regards, - Paul > --- > arch/arm/mach-omap2/omap_device.c | 3 +-- > arch/arm/mach-omap2/omap_hwmod.c | 5 +---- > arch/arm/mach-omap2/timer.c | 3 +-- > 3 files changed, 3 insertions(+), 8 deletions(-) > > diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c > index 4cb8fd9..196366e 100644 > --- a/arch/arm/mach-omap2/omap_device.c > +++ b/arch/arm/mach-omap2/omap_device.c > @@ -193,8 +193,7 @@ static int _omap_device_notifier_call(struct notifier_block *nb, > > switch (event) { > case BUS_NOTIFY_DEL_DEVICE: > - if (pdev->archdata.od) > - omap_device_delete(pdev->archdata.od); > + omap_device_delete(pdev->archdata.od); > break; > case BUS_NOTIFY_ADD_DEVICE: > if (pdev->dev.of_node) > diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c > index d78c12e..1091ee7 100644 > --- a/arch/arm/mach-omap2/omap_hwmod.c > +++ b/arch/arm/mach-omap2/omap_hwmod.c > @@ -921,10 +921,7 @@ static int _disable_clocks(struct omap_hwmod *oh) > int i = 0; > > pr_debug("omap_hwmod: %s: disabling clocks\n", oh->name); > - > - if (oh->_clk) > - clk_disable(oh->_clk); > - > + clk_disable(oh->_clk); > p = oh->slave_ports.next; > > while (i < oh->slaves_cnt) { > diff --git a/arch/arm/mach-omap2/timer.c b/arch/arm/mach-omap2/timer.c > index cac46d8..15448221 100644 > --- a/arch/arm/mach-omap2/timer.c > +++ b/arch/arm/mach-omap2/timer.c > @@ -208,8 +208,7 @@ static void __init omap_dmtimer_init(void) > /* If we are a secure device, remove any secure timer nodes */ > if ((omap_type() != OMAP2_DEVICE_TYPE_GP)) { > np = omap_get_timer_dt(omap_timer_match, "ti,timer-secure"); > - if (np) > - of_node_put(np); > + of_node_put(np); > } > } > > -- > 2.4.5 > - Paul -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
* Paul Walmsley <paul@pwsan.com> [150715 22:58]: > Hello Markus > > On Tue, 30 Jun 2015, SF Markus Elfring wrote: > > > From: Markus Elfring <elfring@users.sourceforge.net> > > Date: Tue, 30 Jun 2015 14:00:16 +0200 > > > > The functions clk_disable(), of_node_put() and omap_device_delete() test > > whether their argument is NULL and then return immediately. > > Thus the test around the call is not needed. > > > > This issue was detected by using the Coccinelle software. > > > > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> > > Thanks for the patch. I have to say, I am a bit leery about applying the > omap_device.c and omap_hwmod.c changes, since the called functions -- > omap_device_delete() and clk_disable() -- don't explicitly document that > NULLs are allowed to be passed in. So there's no explicit contract that > callers can rely upon, to (at least in theory) prevent those internal NULL > pointer checks from being removed. > > So I would suggest that those two functions' kerneldoc be patched first to > explicitly state that passing in a NULL pointer is allowed. Then I would > feel a bit more comfortable applying the omap_device.c and omap_hwmod.c > changes. > > The kerneldoc for of_node_put() does explicitly allow NULLs to be passed > in. So I'll apply that change now for v4.3, touching up the commit > message accordingly. I have them applied from a later thread already, but will drop both in my branch as I have not pushed them out yet. Regards, Tony -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
> I have to say, I am a bit leery about applying the omap_device.c and > omap_hwmod.c changes, since the called functions -- omap_device_delete() > and clk_disable() -- don't explicitly document that NULLs are allowed > to be passed in. How are the chances to improve documentation around such implementation details? > So there's no explicit contract that callers can rely upon, to (at least > in theory) prevent those internal NULL pointer checks from being removed. Are there any additional variations to consider for source files from different processor architectures? > So I would suggest that those two functions' kerneldoc be patched first to > explicitly state that passing in a NULL pointer is allowed. Should my static source code analysis approach help you any more to clarify further open issues? > So I'll apply that change now for v4.3, touching up the commit message accordingly. Thanks for your constructive feedback. >> arch/arm/mach-omap2/omap_device.c | 3 +-- >> arch/arm/mach-omap2/omap_hwmod.c | 5 +---- >> arch/arm/mach-omap2/timer.c | 3 +-- Did Tony Lindgren pick a similar update suggestion up, too? https://lkml.org/lkml/2015/7/15/112 Regards, Markus -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Wed, 15 Jul 2015, Tony Lindgren wrote: > * Paul Walmsley <paul@pwsan.com> [150715 22:58]: > > Hello Markus > > > > On Tue, 30 Jun 2015, SF Markus Elfring wrote: > > > > > From: Markus Elfring <elfring@users.sourceforge.net> > > > Date: Tue, 30 Jun 2015 14:00:16 +0200 > > > > > > The functions clk_disable(), of_node_put() and omap_device_delete() test > > > whether their argument is NULL and then return immediately. > > > Thus the test around the call is not needed. > > > > > > This issue was detected by using the Coccinelle software. > > > > > > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> > > > > Thanks for the patch. I have to say, I am a bit leery about applying the > > omap_device.c and omap_hwmod.c changes, since the called functions -- > > omap_device_delete() and clk_disable() -- don't explicitly document that > > NULLs are allowed to be passed in. So there's no explicit contract that > > callers can rely upon, to (at least in theory) prevent those internal NULL > > pointer checks from being removed. > > > > So I would suggest that those two functions' kerneldoc be patched first to > > explicitly state that passing in a NULL pointer is allowed. Then I would > > feel a bit more comfortable applying the omap_device.c and omap_hwmod.c > > changes. > > > > The kerneldoc for of_node_put() does explicitly allow NULLs to be passed > > in. So I'll apply that change now for v4.3, touching up the commit > > message accordingly. > > I have them applied from a later thread already, but will drop both in > my branch as I have not pushed them out yet. Oops sorry about stepping on your toes - I obviously missed that followup. - Paul -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
* Paul Walmsley <paul@pwsan.com> [150716 07:09]: > On Wed, 15 Jul 2015, Tony Lindgren wrote: > > > * Paul Walmsley <paul@pwsan.com> [150715 22:58]: > > > Hello Markus > > > > > > On Tue, 30 Jun 2015, SF Markus Elfring wrote: > > > > > > > From: Markus Elfring <elfring@users.sourceforge.net> > > > > Date: Tue, 30 Jun 2015 14:00:16 +0200 > > > > > > > > The functions clk_disable(), of_node_put() and omap_device_delete() test > > > > whether their argument is NULL and then return immediately. > > > > Thus the test around the call is not needed. > > > > > > > > This issue was detected by using the Coccinelle software. > > > > > > > > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> > > > > > > Thanks for the patch. I have to say, I am a bit leery about applying the > > > omap_device.c and omap_hwmod.c changes, since the called functions -- > > > omap_device_delete() and clk_disable() -- don't explicitly document that > > > NULLs are allowed to be passed in. So there's no explicit contract that > > > callers can rely upon, to (at least in theory) prevent those internal NULL > > > pointer checks from being removed. > > > > > > So I would suggest that those two functions' kerneldoc be patched first to > > > explicitly state that passing in a NULL pointer is allowed. Then I would > > > feel a bit more comfortable applying the omap_device.c and omap_hwmod.c > > > changes. > > > > > > The kerneldoc for of_node_put() does explicitly allow NULLs to be passed > > > in. So I'll apply that change now for v4.3, touching up the commit > > > message accordingly. > > > > I have them applied from a later thread already, but will drop both in > > my branch as I have not pushed them out yet. > > Oops sorry about stepping on your toes - I obviously missed that followup. No problem :) Tony -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c index 4cb8fd9..196366e 100644 --- a/arch/arm/mach-omap2/omap_device.c +++ b/arch/arm/mach-omap2/omap_device.c @@ -193,8 +193,7 @@ static int _omap_device_notifier_call(struct notifier_block *nb, switch (event) { case BUS_NOTIFY_DEL_DEVICE: - if (pdev->archdata.od) - omap_device_delete(pdev->archdata.od); + omap_device_delete(pdev->archdata.od); break; case BUS_NOTIFY_ADD_DEVICE: if (pdev->dev.of_node) diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c index d78c12e..1091ee7 100644 --- a/arch/arm/mach-omap2/omap_hwmod.c +++ b/arch/arm/mach-omap2/omap_hwmod.c @@ -921,10 +921,7 @@ static int _disable_clocks(struct omap_hwmod *oh) int i = 0; pr_debug("omap_hwmod: %s: disabling clocks\n", oh->name); - - if (oh->_clk) - clk_disable(oh->_clk); - + clk_disable(oh->_clk); p = oh->slave_ports.next; while (i < oh->slaves_cnt) { diff --git a/arch/arm/mach-omap2/timer.c b/arch/arm/mach-omap2/timer.c index cac46d8..15448221 100644 --- a/arch/arm/mach-omap2/timer.c +++ b/arch/arm/mach-omap2/timer.c @@ -208,8 +208,7 @@ static void __init omap_dmtimer_init(void) /* If we are a secure device, remove any secure timer nodes */ if ((omap_type() != OMAP2_DEVICE_TYPE_GP)) { np = omap_get_timer_dt(omap_timer_match, "ti,timer-secure"); - if (np) - of_node_put(np); + of_node_put(np); } }