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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 23 Aug 2016 11:10:21 +0800
From:   Peter Chen <hzpeterchen@...il.com>
To:     Alan Stern <stern@...land.harvard.edu>
Cc:     Peter Chen <peter.chen@....com>, gregkh@...uxfoundation.org,
        ulf.hansson@...aro.org, broonie@...nel.org, sre@...nel.org,
        robh+dt@...nel.org, shawnguo@...nel.org, dbaryshkov@...il.com,
        dwmw3@...radead.org, k.kozlowski@...sung.com,
        linux-arm-kernel@...ts.infradead.org, p.zabel@...gutronix.de,
        devicetree@...r.kernel.org, pawel.moll@....com,
        mark.rutland@....com, linux-usb@...r.kernel.org, arnd@...db.de,
        s.hauer@...gutronix.de, mail@...iej.szmigiero.name,
        troy.kisky@...ndarydevices.com, festevam@...il.com,
        oscar@...andei.net, stephen.boyd@...aro.org,
        linux-pm@...r.kernel.org, stillcompiling@...il.com,
        linux-kernel@...r.kernel.org, mka@...omium.org
Subject: Re: [PATCH v6 4/8] usb: core: add power sequence handling for USB
 devices

On Mon, Aug 22, 2016 at 12:09:54PM -0400, Alan Stern wrote:
> > > +
> > > +static int hub_of_pwrseq_on(struct device_node *np, struct usb_hub *hub)
> > > +{
> > > +	struct pwrseq *pwrseq;
> > > +	struct usb_pwrseq_node *pwrseq_node;
> > > +	int ret;
> > > +
> > > +	pwrseq = pwrseq_alloc_generic();
> > > +	if (IS_ERR(pwrseq))
> > > +		return PTR_ERR(pwrseq);
> > > +
> > > +	ret = pwrseq_get(np, pwrseq);
> > > +	if (ret)
> > > +		goto pwr_free;
> > > +
> > > +	ret = pwrseq_on(np, pwrseq);
> > > +	if (ret)
> > > +		goto pwr_put;
> > > +
> > > +	pwrseq_node = kzalloc(sizeof(*pwrseq_node), GFP_KERNEL);
> 
> You need to check that the kzalloc succeeded.

Ok.

> 
> > > +	pwrseq_node->pwrseq = pwrseq;
> > > +	list_add(&pwrseq_node->list, &hub->pwrseq_on_list);
> > > +
> > > +	return 0;
> > > +
> > > +pwr_put:
> > > +	pwrseq_put(pwrseq);
> > > +pwr_free:
> > > +	pwrseq_free(pwrseq);
> > > +	return ret;
> > > +}
> 
> This subroutine looks very generic.  The only place where it cares that
> it was called for a USB hub is the list_add(), and that could easily
> become generic also (make this function take &hub->pwrseq_on_list as
> its second argument, instead of hub).
> 
> It looks like this routine really belongs in the power sequence 
> library.
> 

I will export below two generic functions at pwrseq library:

int generic_pwrseq_on(struct device_node *np, struct list_head *head)
void generic_pwrseq_off(struct list_head *head)

delete this file, and call above APIs at hub.c.

> > > +
> > > +int hub_pwrseq_on(struct usb_hub *hub)
> > > +{
> 
> The names of this routine and the subroutine above are too similar.  
> After all, both functions require OF support.
> 

I will add #ifdef CONFIG_OF for related code. And put the content at
hub_pwrseq_on at hub_probe directly, how about below?

hub_probe() {

	...

	if (hub_configure(hub, endpoint) >= 0) {
#ifdef CONFIG_OF
		for_each_child_of_node(parent->of_node, np) {
			ret = generic_pwrseq_on(np, hub);
			if (ret)
				return ret;
		}
#else
		return 0;
#endif
	}

	hub_disconnect(intf);
	return ret;
}

-- 

Best Regards,
Peter Chen

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ