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: <201009252255.20933.rjw@sisk.pl>
Date:	Sat, 25 Sep 2010 22:55:20 +0200
From:	"Rafael J. Wysocki" <rjw@...k.pl>
To:	paulmck@...ux.vnet.ibm.com
Cc:	Nishanth Menon <nm@...com>,
	"linux-pm" <linux-pm@...ts.linux-foundation.org>,
	lkml <linux-kernel@...r.kernel.org>,
	"linux-arm" <linux-arm-kernel@...ts.infradead.org>,
	"linux-omap" <linux-omap@...r.kernel.org>
Subject: Re: [PATCH v4] power: introduce library for device-specific OPPs

On Friday, September 24, 2010, Paul E. McKenney wrote:
> On Fri, Sep 24, 2010 at 07:50:40AM -0500, Nishanth Menon wrote:
...
> 
> Looks like a good start!!!  Some questions and suggestions about RCU
> usage interspersed below.
...
> > + * Locking: RCU reader.
> > + */
> > +int opp_get_opp_count(struct device *dev)
> > +{
> > +	struct device_opp *dev_opp;
> > +	struct opp *temp_opp;
> > +	int count = 0;
> > +
> > +	dev_opp = find_device_opp(dev);
> > +	if (IS_ERR(dev_opp))
> > +		return PTR_ERR(dev_opp);
> > +
> > +	rcu_read_lock();
> > +	list_for_each_entry_rcu(temp_opp, &dev_opp->opp_list, node) {
> > +		if (temp_opp->available)
> > +			count++;
> > +	}
> > +	rcu_read_unlock();
> 
> This one is OK as well.  You are returning a count, so if all of the
> counted structures are freed at this point, no problem.  The count was
> valid when it was accumulated, and the fact that it might now be obsolete
> is (usually) not a problem.

However, it looks like it should run rcu_read_lock() before calling
find_device_opp(dev), shouldn't it?

Rafael
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ