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: <022301da6fbf$aae4f7e0$00aee7a0$@samsung.com>
Date: Wed, 6 Mar 2024 17:43:03 +0530
From: "Shradha Todi" <shradha.t@...sung.com>
To: "'Dan Carpenter'" <dan.carpenter@...aro.org>
Cc: <linux-clk@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
	<linux-pci@...r.kernel.org>, <linux-arm-kernel@...ts.infradead.org>,
	<linux-samsung-soc@...r.kernel.org>, <mturquette@...libre.com>,
	<sboyd@...nel.org>, <jingoohan1@...il.com>, <lpieralisi@...nel.org>,
	<kw@...ux.com>, <robh@...nel.org>, <bhelgaas@...gle.com>,
	<krzysztof.kozlowski@...aro.org>, <alim.akhtar@...sung.com>,
	<linux@...linux.org.uk>, <m.szyprowski@...sung.com>,
	<manivannan.sadhasivam@...aro.org>, <pankaj.dubey@...sung.com>,
	<gost.dev@...sung.com>
Subject: RE: [PATCH v6 1/2] clk: Provide managed helper to get and enable
 bulk clocks



> -----Original Message-----
> From: Dan Carpenter <dan.carpenter@...aro.org>
> Sent: 05 March 2024 14:20
> To: Shradha Todi <shradha.t@...sung.com>
> Cc: linux-clk@...r.kernel.org; linux-kernel@...r.kernel.org; linux-
> pci@...r.kernel.org; linux-arm-kernel@...ts.infradead.org; linux-samsung-
> soc@...r.kernel.org; mturquette@...libre.com; sboyd@...nel.org;
> jingoohan1@...il.com; lpieralisi@...nel.org; kw@...ux.com; robh@...nel.org;
> bhelgaas@...gle.com; krzysztof.kozlowski@...aro.org;
> alim.akhtar@...sung.com; linux@...linux.org.uk;
> m.szyprowski@...sung.com; manivannan.sadhasivam@...aro.org;
> pankaj.dubey@...sung.com; gost.dev@...sung.com
> Subject: Re: [PATCH v6 1/2] clk: Provide managed helper to get and enable bulk
> clocks
> 
> On Tue, Feb 20, 2024 at 02:10:45PM +0530, Shradha Todi wrote:
> > +int __must_check devm_clk_bulk_get_all_enable(struct device *dev,
> > +					      struct clk_bulk_data **clks) {
> > +	struct clk_bulk_devres *devres;
> > +	int ret;
> > +
> > +	devres = devres_alloc(devm_clk_bulk_release_all_enable,
> > +			      sizeof(*devres), GFP_KERNEL);
> > +	if (!devres)
> > +		return -ENOMEM;
> > +
> > +	ret = clk_bulk_get_all(dev, &devres->clks);
> > +	if (ret > 0) {
> 
> I feel like this should be >= instead of >.  There aren't any callers of this
function
> yet so we can't see what's in *clks at the start but it's easy to imagine a
situation
> where it's bad data.
> 

Reference for this piece of code has been taken from devm_clk_bulk_get_all()
which
has multiple callers, so it's safe. If we make this >=, it will hold on to the
devres node
even though there are no clocks.

> > +		*clks = devres->clks;
> > +		devres->num_clks = ret;
> > +	} else {
> > +		devres_free(devres);
> > +		return ret;
> 
> When clk_bulk_get_all() returns zero then we return success here.
> 

Yes, we are returning success in case there are no clocks as well. In case there
are no
clocks defined in the DT-node, then it is assumed that the driver does not need
any
clock manipulation for driver operation. So the intention here is to continue
without
throwing error.

> regards,
> dan carpenter
> 
> > +	}
> > +
> > +	ret = clk_bulk_prepare_enable(devres->num_clks, *clks);
> > +	if (!ret) {
> > +		devres_add(dev, devres);
> > +	} else {
> > +		clk_bulk_put_all(devres->num_clks, devres->clks);
> > +		devres_free(devres);
> > +	}
> > +
> > +	return ret;
> > +}
> > +EXPORT_SYMBOL_GPL(devm_clk_bulk_get_all_enable);
> > +



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ