lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 8 Apr 2016 20:15:05 +0900
From:	Masahiro Yamada <yamada.masahiro@...ionext.com>
To:	Ralf Baechle <ralf@...ux-mips.org>,
	Stephen Boyd <sboyd@...eaurora.org>
Cc:	linux-mips@...ux-mips.org, linux-m68k@...r.kernel.org,
	Rich Felker <dalias@...c.org>, linux-sh@...r.kernel.org,
	Tony Lindgren <tony@...mide.com>,
	Michael Turquette <mturquette@...libre.com>,
	Sekhar Nori <nsekhar@...com>, Greg Ungerer <gerg@...inux.org>,
	linux-clk@...r.kernel.org,
	Hans-Christian Egtvedt <egtvedt@...fundet.no>,
	Russell King <linux@....linux.org.uk>,
	Yoshinori Sato <ysato@...rs.sourceforge.jp>,
	Kevin Hilman <khilman@...nel.org>,
	Magnus Damm <magnus.damm@...il.com>,
	Geert Uytterhoeven <geert@...ux-m68k.org>,
	Haavard Skinnemoen <hskinnemoen@...il.com>,
	Wan ZongShun <mcuos.com@...il.com>,
	Steven Miao <realmz6@...il.com>,
	adi-buildroot-devel@...ts.sourceforge.net,
	Haojian Zhuang <haojian.zhuang@...il.com>,
	Simon Horman <horms@...ge.net.au>, linux-omap@...r.kernel.org,
	linux-arm-kernel <linux-arm-kernel@...ts.infradead.org>,
	John Crispin <blogic@...nwrt.org>,
	Paul Walmsley <paul@...an.com>,
	Eric Miao <eric.y.miao@...il.com>,
	Ryan Mallon <rmallon@...il.com>,
	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
	linux-renesas-soc@...r.kernel.org,
	Hartley Sweeten <hsweeten@...ionengravers.com>
Subject: Re: [PATCH v2] clk: let clk_disable() return immediately if clk is
 NULL or error

2016-04-08 19:06 GMT+09:00 Ralf Baechle <ralf@...ux-mips.org>:
> On Thu, Apr 07, 2016 at 05:33:28PM -0700, Stephen Boyd wrote:
>
>> On 04/05, Masahiro Yamada wrote:
>> > The clk_disable() in the common clock framework (drivers/clk/clk.c)
>> > returns immediately if a given clk is NULL or an error pointer.  It
>> > allows clock consumers to call clk_disable() without IS_ERR_OR_NULL
>> > checking if drivers are only used with the common clock framework.
>> >
>> > Unfortunately, NULL/error checking is missing from some of non-common
>> > clk_disable() implementations.  This prevents us from completely
>> > dropping NULL/error checking from callers.  Let's make it tree-wide
>> > consistent by adding IS_ERR_OR_NULL(clk) to all callees.
>> >
>> > Signed-off-by: Masahiro Yamada <yamada.masahiro@...ionext.com>
>> > Acked-by: Greg Ungerer <gerg@...inux.org>
>> > Acked-by: Wan Zongshun <mcuos.com@...il.com>
>> > ---
>> >
>> > Stephen,
>> >
>> > This patch has been unapplied for a long time.
>> >
>> > Please let me know if there is something wrong with this patch.
>> >
>>
>> I'm mostly confused why we wouldn't want to encourage people to
>> call clk_disable or unprepare on a clk that's an error pointer.
>> Typically an error pointer should be dealt with, instead of
>> silently ignored, so why wasn't it dealt with by passing it up
>> the probe() path?
>
> While your argument makes perfect sense, Many clk_disable implementations
> are already doing similar checks, for example:
>
> arch/arm/mach-davinci/clock.c:
>
> void clk_disable(struct clk *clk)
> {
>         unsigned long flags;
>
>         if (clk == NULL || IS_ERR(clk))
>                 return;
> [...]
>
> arch/arm/mach-omap1/clock.c
>
> void clk_disable(struct clk *clk)
> {
>         unsigned long flags;
>
>         if (clk == NULL || IS_ERR(clk))
>                 return;
> [...]
>
> arch/avr32/mach-at32ap/clock.c
>
> void clk_disable(struct clk *clk)
> {
>         unsigned long flags;
>
>         if (IS_ERR_OR_NULL(clk))
>                 return;
> [...]
>
> arch/mips/lantiq/clk.c:
>
> static inline int clk_good(struct clk *clk)
> {
>         return clk && !IS_ERR(clk);
> }
>
> [...]
>
> void clk_disable(struct clk *clk)
> {
>         if (unlikely(!clk_good(clk)))
>                 return;
>
>         if (clk->disable)
> [...]
>
> So should we go and weed out these checks?
>
>   Ralf


Please help me understand your thought clearly.

[1] Should calling clk_unprepare/disable() with a NULL pointer be allowed?

[2] Should calling clk_unprepare/disable() with an error pointer be allowed?


-- 
Best Regards
Masahiro Yamada

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ