* net: cdc_ncm: initialize drvflags before usage
@ 2018-02-01 13:49 Porto Rio
2018-02-01 17:14 ` Greg KH
0 siblings, 1 reply; 2+ messages in thread
From: Porto Rio @ 2018-02-01 13:49 UTC (permalink / raw)
To: stable; +Cc: Enrico Mioso
Hi all,
we detected a problem in stable Kernel 4.4.114 in drivers/net/usb/cdc_ncm.c. In line 833, ctx->drvflags is checked in the if clause:
if (ctx->drvflags & CDC_NCM_FLAG_RESET_NTB16) {
but it is initialized *later* in line 877:
/* Device-specific flags */
ctx->drvflags = drvflags;
This initialization has to be done before the if clause.
Note, that the if clause was backported from mainline at Nov. 15th 2017 (GetNtbFormat endian fix). In mainline, the initialization is at the right place before the if clause.
Please find here a suggested patch:
--- linux/drivers/net/usb/cdc_ncm.c.orig 2018-02-01 13:55:20.034393993 +0100
+++ linux/drivers/net/usb/cdc_ncm.c 2018-02-01 13:56:12.842393881 +0100
@@ -825,6 +825,9 @@ int cdc_ncm_bind_common(struct usbnet *d
goto error2;
}
+ /* Device-specific flags */
+ ctx->drvflags = drvflags;
+
/*
* Some Huawei devices have been observed to come out of reset in NDP32 mode.
* Let's check if this is the case, and set the device to NDP16 mode again if
@@ -873,9 +876,6 @@ int cdc_ncm_bind_common(struct usbnet *d
/* finish setting up the device specific data */
cdc_ncm_setup(dev);
- /* Device-specific flags */
- ctx->drvflags = drvflags;
-
/* Allocate the delayed NDP if needed. */
if (ctx->drvflags & CDC_NCM_FLAG_NDP_TO_END) {
ctx->delayed_ndp16 = kzalloc(ctx->max_ndp_size, GFP_KERNEL);
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: net: cdc_ncm: initialize drvflags before usage
2018-02-01 13:49 net: cdc_ncm: initialize drvflags before usage Porto Rio
@ 2018-02-01 17:14 ` Greg KH
0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2018-02-01 17:14 UTC (permalink / raw)
To: Porto Rio; +Cc: stable, Enrico Mioso
On Thu, Feb 01, 2018 at 02:49:38PM +0100, Porto Rio wrote:
> Hi all,
>
> we detected a problem in stable Kernel 4.4.114 in drivers/net/usb/cdc_ncm.c. In line 833, ctx->drvflags is checked in the if clause:
>
> if (ctx->drvflags & CDC_NCM_FLAG_RESET_NTB16) {
>
> but it is initialized *later* in line 877:
>
> /* Device-specific flags */
> ctx->drvflags = drvflags;
>
> This initialization has to be done before the if clause.
>
> Note, that the if clause was backported from mainline at Nov. 15th 2017 (GetNtbFormat endian fix). In mainline, the initialization is at the right place before the if clause.
>
> Please find here a suggested patch:
>
>
>
> --- linux/drivers/net/usb/cdc_ncm.c.orig 2018-02-01 13:55:20.034393993 +0100
> +++ linux/drivers/net/usb/cdc_ncm.c 2018-02-01 13:56:12.842393881 +0100
> @@ -825,6 +825,9 @@ int cdc_ncm_bind_common(struct usbnet *d
> goto error2;
> }
>
> + /* Device-specific flags */
> + ctx->drvflags = drvflags;
> +
> /*
> * Some Huawei devices have been observed to come out of reset in NDP32 mode.
> * Let's check if this is the case, and set the device to NDP16 mode again if
> @@ -873,9 +876,6 @@ int cdc_ncm_bind_common(struct usbnet *d
> /* finish setting up the device specific data */
> cdc_ncm_setup(dev);
>
> - /* Device-specific flags */
> - ctx->drvflags = drvflags;
> -
> /* Allocate the delayed NDP if needed. */
> if (ctx->drvflags & CDC_NCM_FLAG_NDP_TO_END) {
> ctx->delayed_ndp16 = kzalloc(ctx->max_ndp_size, GFP_KERNEL);
Nice catch, care to resend this in a format I can apply it in, with a
signed-off-by and everything?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-02-01 17:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-01 13:49 net: cdc_ncm: initialize drvflags before usage Porto Rio
2018-02-01 17:14 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).