Skip to contentSkip to conversation

usbnet: fix memory allocation in helpers

PATCH Applied Oliver Neukum 2 participants 2 messages Jun 28, 2022 – Jun 30, 2022

Subsystems (5)
lore
Share & tools
lore

Oliver Neukum

author maintainer
#0 lore raw

PATCH 1/1 usbnet: fix memory allocation in helpers

usbnet provides some helper functions that are also used in the context of reset() operations. During a reset the other drivers on a device are unable to operate. As that can be block drivers, a driver for another interface cannot use paging in its memory allocations without risking a deadlock. Use GFP_NOIO in the helpers.

Fixes 877bd862f32b8 ("usbnet: introduce usbnet 3 command helpers")
---
 drivers/net/usb/usbnet.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/usb/usbnet.c +2 -2
index c66d2a097b0c..02b915b1e142 100644
@@ -2004,7 +2004,7 @@ static int __usbnet_read_cmd(struct usbnet *dev, u8 cmd, u8 reqtype,
 		   cmd, reqtype, value, index, size);
 
 	if (size) {
-		buf = kmalloc(size, GFP_KERNEL);
+		buf = kmalloc(size, GFP_NOIO);
 		if (!buf)
 			goto out;
 	}
@@ -2036,7 +2036,7 @@ static int __usbnet_write_cmd(struct usbnet *dev, u8 cmd, u8 reqtype,
 		   cmd, reqtype, value, index, size);
 
 	if (data) {
-		buf = kmemdup(data, size, GFP_KERNEL);
+		buf = kmemdup(data, size, GFP_NOIO);
 		if (!buf)
 			goto out;
 	} else {
Signature · 1 line
2.35.3
#1 lore raw
This patch was applied to netdev/net.git (master) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (master)
by Jakub Kicinski <[email protected]>:

Quoted 8 lines · On Tue, 28 Jun 2022 11:35:17 +0200 you wrote:

usbnet provides some helper functions that are also used in the context of reset() operations. During a reset the other drivers on a device are unable to operate. As that can be block drivers, a driver for another interface cannot use paging in its memory allocations without risking a deadlock. Use GFP_NOIO in the helpers.

[...]

Here is the summary with links:
- usbnet: fix memory allocation in helpers

    https://git.kernel.org/netdev/net/c/e65af5403e46

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html