Skip to contentSkip to conversation

net: cdc_ncm: initialize drvflags before usage

PATCH Applied Matthias 2 participants 2 messages Feb 6, 2018

Subsystems (4)
lore
Share & tools
lore

Matthias

author
#0 lore raw

PATCH v2 1/1 net: cdc_ncm: initialize drvflags before usage

From: Matthias Hintzmann <[email protected]>

ctx->drvflags is checked in the if clause before beeing initialized. Move initialization before first usage.

Note, that the if clause was backported with commit 75f82a703b30 ("cdc_ncm: Set NTB format again after altsetting switch for Huawei devices") from mainline (upstream commit 2b02c20ce0c2 ("cdc_ncm: Set NTB format again after altsetting switch for Huawei devices"). In mainline, the initialization is at the right place before the if clause.

Fixes 75f82a703b30 ("cdc_ncm: Set NTB format again after altsetting switch for Huawei devices")
[[email protected]: commit message tweaks]
---
 drivers/net/usb/cdc_ncm.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/usb/cdc_ncm.c +3 -3
index 1228d0da407..72cb30828a1 100644
@@ -825,6 +825,9 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_
 		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 *dev, struct usb_interface *intf, u8 data_
 	/* 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);
Signature · 1 line
2.15.1
maintainer Applied
#1 lore raw

Patch "net: cdc_ncm: initialize drvflags before usage" has been added to the 4.4-stable tree

This is a note to let you know that I've just added the patch titled

net: cdc_ncm: initialize drvflags before usage

to the 4.4-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
net-cdc_ncm-initialize-drvflags-before-usage.patch
and it can be found in the queue-4.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From [email protected] Tue Feb 6 12:26:56 2018

From: Matthias <[email protected]>
Date: Tue, 6 Feb 2018 20:59:01 +0100
Subject: net: cdc_ncm: initialize drvflags before usage
To: [email protected]
Cc: [email protected]
Message-ID: <[email protected]>

From: Matthias Hintzmann <[email protected]>

ctx->drvflags is checked in the if clause before beeing initialized. Move initialization before first usage.

Note, that the if clause was backported with commit 75f82a703b30 ("cdc_ncm: Set NTB format again after altsetting switch for Huawei devices") from mainline (upstream commit 2b02c20ce0c2 ("cdc_ncm: Set NTB format again after altsetting switch for Huawei devices"). In mainline, the initialization is at the right place before the if clause.

[[email protected]: commit message tweaks]

Fixes 75f82a703b30 ("cdc_ncm: Set NTB format again after altsetting switch for Huawei devices")
---
 drivers/net/usb/cdc_ncm.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/usb/cdc_ncm.c +3 -3
@@ -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);

Patches currently in stable-queue which might be from [email protected] are

queue-4.4/net-cdc_ncm-initialize-drvflags-before-usage.patch