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:	Mon, 30 Sep 2013 11:07:53 +0200
From:	Oliver Neukum <oneukum@...e.de>
To:	Enrico Mioso <mrkiko.rs@...il.com>
Cc:	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	"David S. Miller" <davem@...emloft.net>,
	Steve Glendinning <steve.glendinning@...well.net>,
	Robert de Vries <rhdv@...all.nl>,
	Hayes Wang <hayeswang@...ltek.com>,
	Freddy Xin <freddy@...x.com.tw>,
	Bjørn Mork <bjorn@...k.no>,
	Liu Junliang <liujunliang_ljl@....com>,
	open list <linux-kernel@...r.kernel.org>,
	"open list:USB NETWORKING DR..." <linux-usb@...r.kernel.org>,
	"open list:NETWORKING DRIVERS" <netdev@...r.kernel.org>,
	ModemManager-devel@...ts.freedesktop.org
Subject: Re: [PATCH V5 net-next 2/3] net: huawei_cdc_ncm: Introduce the
 huawei_cdc_ncm driver

On Mon, 2013-09-30 at 04:50 +0000, Enrico Mioso wrote:

> +static int huawei_cdc_ncm_manage_power(struct usbnet *usbnet_dev, int on)
> +{
> +	struct huawei_cdc_ncm_state *drvstate = (void *)&usbnet_dev->data;
> +	int rv = 0;
> +
> +	if ((on && atomic_add_return(1, &drvstate->pmcount) == 1) ||
> +			(!on && atomic_dec_and_test(&drvstate->pmcount))) {
> +		rv = usb_autopm_get_interface(usbnet_dev->intf);
> +		if (rv < 0)
> +			goto err;

The error case corrupts drvstate->pmcount

> +		usbnet_dev->intf->needs_remote_wakeup = on;
> +		usb_autopm_put_interface(usbnet_dev->intf);
> +	}
> +err:
> +	return rv;
> +}


> +static int huawei_cdc_ncm_suspend(struct usb_interface *intf, pm_message_t message)
> +{
> +	int ret = 0;
> +	struct usbnet *usbnet_dev = usb_get_intfdata(intf);
> +	struct huawei_cdc_ncm_state *drvstate = (void *)&usbnet_dev->data;
> +	struct cdc_ncm_ctx *ctx = drvstate->ctx;
> +
> +	if (ctx == NULL) {
> +		ret = -1;

That is not a valid way to indicate an error.

> +		goto error;
> +	}
> +
> +	ret = usbnet_suspend(intf, message);
> +	if (ret < 0)
> +		goto error;
> +
> +	if (intf == ctx->control &&
> +		drvstate->subdriver &&
> +		drvstate->subdriver->suspend)
> +		ret = drvstate->subdriver->suspend(intf, message);
> +	if (ret < 0)
> +		usbnet_resume(intf);
> +
> +error:
> +	return ret;
> +}
> +
> +static int huawei_cdc_ncm_resume(struct usb_interface *intf)
> +{
> +	int ret = 0;
> +	struct usbnet *usbnet_dev = usb_get_intfdata(intf);
> +	struct huawei_cdc_ncm_state *drvstate = (void *)&usbnet_dev->data;
> +	bool callsub;
> +	struct cdc_ncm_ctx *ctx = drvstate->ctx;
> +
> +	/* should we call subdriver's resume function? */
> +	callsub =
> +		(intf == ctx->control &&
> +		drvstate->subdriver &&
> +		drvstate->subdriver->resume);
> +
> +	if (callsub)
> +		ret = drvstate->subdriver->resume(intf);
> +	if (ret < 0)
> +		goto err;
> +	ret = usbnet_resume(intf);
> +	if (ret < 0 && callsub && drvstate->subdriver->suspend)

You really want drivers with a resume() but no suspend() method?

> +		drvstate->subdriver->suspend(intf, PMSG_SUSPEND);
> +err:
> +	return ret;
> +}

	Regards
		Oliver


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ