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]
Message-ID: <20160414003341.GH14441@codeaurora.org>
Date:	Wed, 13 Apr 2016 17:33:41 -0700
From:	Stephen Boyd <sboyd@...eaurora.org>
To:	Masahiro Yamada <yamada.masahiro@...ionext.com>
Cc:	linux-clk@...r.kernel.org, Ralf Baechle <ralf@...ux-mips.org>,
	Michael Turquette <mturquette@...libre.com>,
	linux-mips@...ux-mips.org, linux-sh@...r.kernel.org,
	Haojian Zhuang <haojian.zhuang@...il.com>,
	Eric Miao <eric.y.miao@...il.com>,
	Hartley Sweeten <hsweeten@...ionengravers.com>,
	Greg Ungerer <gerg@...inux.org>,
	Ryan Mallon <rmallon@...il.com>,
	Geert Uytterhoeven <geert@...ux-m68k.org>,
	Steven Miao <realmz6@...il.com>,
	Simon Horman <horms@...ge.net.au>,
	Wan ZongShun <mcuos.com@...il.com>,
	Rich Felker <dalias@...c.org>,
	Yoshinori Sato <ysato@...rs.sourceforge.jp>,
	adi-buildroot-devel@...ts.sourceforge.net,
	Russell King <linux@....linux.org.uk>,
	linux-m68k@...ts.linux-m68k.org,
	linux-arm-kernel <linux-arm-kernel@...ts.infradead.org>,
	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
	linux-renesas-soc@...r.kernel.org,
	Magnus Damm <magnus.damm@...il.com>,
	John Crispin <blogic@...nwrt.org>
Subject: Re: [PATCH v2] clk: let clk_disable() return immediately if clk is
 NULL or error

On 04/08, Masahiro Yamada wrote:
> 
> 
> This makes our driver programming life easier.
> 
> 
> For example, let's see drivers/tty/serial/8250/8250_of.c
> 
> 
> The "clock-frequency" DT property takes precedence over "clocks" property.
> So, it is valid to probe the driver with a NULL pointer for info->clk.
> 
> 
>         if (of_property_read_u32(np, "clock-frequency", &clk)) {
> 
>                 /* Get clk rate through clk driver if present */
>                 info->clk = devm_clk_get(&ofdev->dev, NULL);
>                 if (IS_ERR(info->clk)) {
>                         dev_warn(&ofdev->dev,
>                                 "clk or clock-frequency not defined\n");
>                         return PTR_ERR(info->clk);
>                 }
> 
>                 ret = clk_prepare_enable(info->clk);
>                 if (ret < 0)
>                         return ret;
> 
>                 clk = clk_get_rate(info->clk);
>         }
> 
> 
> As a result, we need to make sure the clk pointer is valid
> before calling clk_disable_unprepare().
> 
> 
> If we could support pointer checking in callees, we would be able to
> clean-up lots of clock consumers.
> 
> 

I'm not sure if you meant to use that example for the error
pointer case? It bails out if clk_get() returns an error pointer.

I'm all for a no-op in clk_disable()/unprepare() when the pointer
is NULL. But when it's an error pointer the driver should be
handling it and bail out before it would ever call enable/prepare
on it or disable/unprepare.

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ