* [PATCH v1 1/1] net/9p/usbg: fix handling of the failed kzalloc() memory allocation
@ 2024-11-09 21:18 Mirsad Todorovac
2024-11-16 8:25 ` Dominique Martinet
0 siblings, 1 reply; 3+ messages in thread
From: Mirsad Todorovac @ 2024-11-09 21:18 UTC (permalink / raw)
To: Michael Grzeschik, Mirsad Todorovac, v9fs, linux-kernel
Cc: Eric Van Hensbergen, Latchesar Ionkov, Dominique Martinet,
Christian Schoenebeck
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: a3be076dc174d ("net/9p/usbg: Add new usb gadget function transport")
Cc: Michael Grzeschik <m.grzeschik@pengutronix.de>
Cc: Eric Van Hensbergen <ericvh@kernel.org>
Cc: Latchesar Ionkov <lucho@ionkov.net>
Cc: Dominique Martinet <asmadeus@codewreck.org>
Cc: Christian Schoenebeck <linux_oss@crudebyte.com>
Cc: v9fs@lists.linux.dev
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Mirsad Todorovac <mtodorovac69@gmail.com>
---
v1:
initial version.
net/9p/trans_usbg.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/9p/trans_usbg.c b/net/9p/trans_usbg.c
index 975b76839dca..6b694f117aef 100644
--- a/net/9p/trans_usbg.c
+++ b/net/9p/trans_usbg.c
@@ -909,9 +909,9 @@ static struct usb_function_instance *usb9pfs_alloc_instance(void)
usb9pfs_opts->buflen = DEFAULT_BUFLEN;
dev = kzalloc(sizeof(*dev), GFP_KERNEL);
- if (IS_ERR(dev)) {
+ if (!dev) {
kfree(usb9pfs_opts);
- return ERR_CAST(dev);
+ return ERR_PTR(-ENOMEM);
}
usb9pfs_opts->dev = dev;
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v1 1/1] net/9p/usbg: fix handling of the failed kzalloc() memory allocation
2024-11-09 21:18 [PATCH v1 1/1] net/9p/usbg: fix handling of the failed kzalloc() memory allocation Mirsad Todorovac
@ 2024-11-16 8:25 ` Dominique Martinet
2024-12-11 21:42 ` Mirsad Todorovac
0 siblings, 1 reply; 3+ messages in thread
From: Dominique Martinet @ 2024-11-16 8:25 UTC (permalink / raw)
To: Mirsad Todorovac
Cc: Michael Grzeschik, v9fs, linux-kernel, Eric Van Hensbergen,
Latchesar Ionkov, Christian Schoenebeck
Mirsad Todorovac wrote on Sat, Nov 09, 2024 at 10:18:41PM +0100:
> 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.
Thank you, I've taken this in 9p-next and will submit it to Linus next
cycle
--
Dominique
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v1 1/1] net/9p/usbg: fix handling of the failed kzalloc() memory allocation
2024-11-16 8:25 ` Dominique Martinet
@ 2024-12-11 21:42 ` Mirsad Todorovac
0 siblings, 0 replies; 3+ messages in thread
From: Mirsad Todorovac @ 2024-12-11 21:42 UTC (permalink / raw)
To: Dominique Martinet
Cc: Michael Grzeschik, v9fs, linux-kernel, Eric Van Hensbergen,
Latchesar Ionkov, Christian Schoenebeck
Hi,
On 11/16/24 09:25, Dominique Martinet wrote:
> Mirsad Todorovac wrote on Sat, Nov 09, 2024 at 10:18:41PM +0100:
>> 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.
>
> Thank you, I've taken this in 9p-next and will submit it to Linus next
> cycle
Hi, Dominique,
Sorry for the late reply, but yes, it is perfectly OK for the patch to go with the
next cycle.
I confirm I can see the commit in the torvalds tree, so this is a minor patch (+2/-2 lines),
but a proof of concept that it can be done.
Best regards,
Mirsad Todorovac
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-12-11 21:43 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-09 21:18 [PATCH v1 1/1] net/9p/usbg: fix handling of the failed kzalloc() memory allocation Mirsad Todorovac
2024-11-16 8:25 ` Dominique Martinet
2024-12-11 21:42 ` Mirsad Todorovac
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox