Skip to content

Commit ff10608

Browse files
Mirsad Todorovacmartinetd
authored andcommitted
net/9p/usbg: fix handling of the failed kzalloc() memory allocation
On the linux-next, next-20241108 vanilla kernel, the coccinelle tool gave the following error report: ./net/9p/trans_usbg.c:912:5-11: ERROR: allocation function on line 911 returns NULL not ERR_PTR on failure kzalloc() failure is fixed to handle the NULL return case on the memory exhaustion. Fixes: a3be076 ("net/9p/usbg: Add new usb gadget function transport") Cc: Michael Grzeschik <[email protected]> Cc: Eric Van Hensbergen <[email protected]> Cc: Latchesar Ionkov <[email protected]> Cc: Dominique Martinet <[email protected]> Cc: Christian Schoenebeck <[email protected]> Cc: [email protected] Cc: [email protected] Signed-off-by: Mirsad Todorovac <[email protected]> Message-ID: <[email protected]> Signed-off-by: Dominique Martinet <[email protected]>
1 parent 45c5b88 commit ff10608

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

net/9p/trans_usbg.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -909,9 +909,9 @@ static struct usb_function_instance *usb9pfs_alloc_instance(void)
909909
usb9pfs_opts->buflen = DEFAULT_BUFLEN;
910910

911911
dev = kzalloc(sizeof(*dev), GFP_KERNEL);
912-
if (IS_ERR(dev)) {
912+
if (!dev) {
913913
kfree(usb9pfs_opts);
914-
return ERR_CAST(dev);
914+
return ERR_PTR(-ENOMEM);
915915
}
916916

917917
usb9pfs_opts->dev = dev;

0 commit comments

Comments
 (0)