All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Bjørn Mork" <bjorn@mork.no>
To: Oliver Neukum <oneukum@suse.de>
Cc: Enrico Mioso <mrkiko.rs@gmail.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"David S. Miller" <davem@davemloft.net>,
	Steve Glendinning <steve.glendinning@shawell.net>,
	Robert de Vries <rhdv@xs4all.nl>,
	Hayes Wang <hayeswang@realtek.com>,
	Freddy Xin <freddy@asix.com.tw>,
	Liu Junliang <liujunliang_ljl@163.com>,
	open list <linux-kernel@vger.kernel.org>,
	"open list\:USB NETWORKING DR..." <linux-usb@vger.kernel.org>,
	"open list\:NETWORKING DRIVERS" <netdev@vger.kernel.org>,
	ModemManager-devel@lists.freedesktop.org
Subject: Re: [PATCH V5 net-next 2/3] net: huawei_cdc_ncm: Introduce the huawei_cdc_ncm driver
Date: Fri, 01 Nov 2013 12:35:45 +0100	[thread overview]
Message-ID: <87fvrgwe0e.fsf@nemi.mork.no> (raw)
In-Reply-To: <1380532073.1484.15.camel@linux-fkkt.site> (Oliver Neukum's message of "Mon, 30 Sep 2013 11:07:53 +0200")

Oliver Neukum <oneukum@suse.de> writes:
> 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;
>> +}

Hello Oliver,

I finally got around to looking closer at this and you are of course
correct.  This is all my fault when I initially wrapped the
needs_remote_wakeup update in usb_autopm_{get,put}_interface,

And the problem is not only here in this new driver, but *everywhere* I
did this, including in cdc-wdm.  That driver doesn't have the counter to
corrupt, but failing to update intf->needs_remote_wakeup if
usb_autopm_get_interface fails is still wrong. The get/put were only
added to make the change take effect immediately.  Things sort of worked
fine before that, and ignoring a get error would only revert to that
older behaviour.

So I believe we should do the update unconditionally, and but skip
usb_autopm_put_interface if the get failed.  Accordingly, these
functions should always return 0 (not that there is anything currently
checking the return anyway).

I'll prepare patches for cdc-wdm, qmi_wwan and cdc_mbim.


Bjørn

  reply	other threads:[~2013-11-01 11:36 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-30  4:50 [PATCH V5 net-next 0/3] The huawei_cdc_ncm driver Enrico Mioso
2013-09-30  4:50 ` [PATCH V5 net-next 1/3] net: cdc_ncm: Export cdc_ncm_{tx,rx}_fixup functions for re-use Enrico Mioso
2013-09-30  4:50 ` [PATCH V5 net-next 2/3] net: huawei_cdc_ncm: Introduce the huawei_cdc_ncm driver Enrico Mioso
2013-09-30  4:50   ` Enrico Mioso
2013-09-30  9:07   ` Oliver Neukum
2013-11-01 11:35     ` Bjørn Mork [this message]
2013-11-04  9:17       ` Oliver Neukum
2013-09-30  4:50 ` [PATCH V5 net-next 3/3] net: cdc_ncm: remove non-standard NCM device IDs Enrico Mioso
2013-09-30  4:50   ` Enrico Mioso
2013-09-30  8:56 ` [PATCH V5 net-next 0/3] The huawei_cdc_ncm driver Bjørn Mork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87fvrgwe0e.fsf@nemi.mork.no \
    --to=bjorn@mork.no \
    --cc=ModemManager-devel@lists.freedesktop.org \
    --cc=davem@davemloft.net \
    --cc=freddy@asix.com.tw \
    --cc=gregkh@linuxfoundation.org \
    --cc=hayeswang@realtek.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=liujunliang_ljl@163.com \
    --cc=mrkiko.rs@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=oneukum@suse.de \
    --cc=rhdv@xs4all.nl \
    --cc=steve.glendinning@shawell.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.