* [PATCH] usbip: tools: Check allocation of exported devices
@ 2026-11-20 6:21 Zhu Jun
2026-11-20 6:26 ` sashiko-bot
2026-11-20 6:39 ` Greg KH
0 siblings, 2 replies; 3+ messages in thread
From: Zhu Jun @ 2026-11-20 6:21 UTC (permalink / raw)
To: valentina.manea.m; +Cc: shuah, i, gregkh, linux-usb, Zhu Jun
usbip_exported_device_new() dereferences edev immediately after calloc()
without checking whether the allocation succeeded. An allocation failure
therefore crashes the tool instead of allowing its caller to skip the
device.
Return NULL before accessing edev when calloc() fails.
Fixes: 021aed845303 ("staging: usbip: userspace: migrate usbip_host_driver to libudev")
Signed-off-by: Zhu Jun <zhujun2@cmss.chinamobile.com>
---
tools/usb/usbip/libsrc/usbip_host_common.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tools/usb/usbip/libsrc/usbip_host_common.c b/tools/usb/usbip/libsrc/usbip_host_common.c
index 01599cb2fa7b..bec6c42e29c8 100644
--- a/tools/usb/usbip/libsrc/usbip_host_common.c
+++ b/tools/usb/usbip/libsrc/usbip_host_common.c
@@ -71,6 +71,8 @@ struct usbip_exported_device *usbip_exported_device_new(
int i;
edev = calloc(1, sizeof(struct usbip_exported_device));
+ if (!edev)
+ return NULL;
edev->sudev =
udev_device_new_from_syspath(udev_context, sdevpath);
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] usbip: tools: Check allocation of exported devices
2026-11-20 6:21 [PATCH] usbip: tools: Check allocation of exported devices Zhu Jun
@ 2026-11-20 6:26 ` sashiko-bot
2026-11-20 6:39 ` Greg KH
1 sibling, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-11-20 6:26 UTC (permalink / raw)
To: Zhu Jun; +Cc: linux-usb
> usbip_exported_device_new() dereferences edev immediately after calloc()
> without checking whether the allocation succeeded. An allocation failure
> therefore crashes the tool instead of allowing its caller to skip the
> device.
>
> Return NULL before accessing edev when calloc() fails.
>
> Fixes: 021aed845303 ("staging: usbip: userspace: migrate usbip_host_driver to libudev")
> Signed-off-by: Zhu Jun <zhujun2@cmss.chinamobile.com>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261120062111.98404-1-zhujun2@cmss.chinamobile.com?part=1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] usbip: tools: Check allocation of exported devices
2026-11-20 6:21 [PATCH] usbip: tools: Check allocation of exported devices Zhu Jun
2026-11-20 6:26 ` sashiko-bot
@ 2026-11-20 6:39 ` Greg KH
1 sibling, 0 replies; 3+ messages in thread
From: Greg KH @ 2026-11-20 6:39 UTC (permalink / raw)
To: Zhu Jun; +Cc: valentina.manea.m, shuah, i, linux-usb
On Fri, Nov 20, 2026 at 02:21:11PM +0800, Zhu Jun wrote:
> usbip_exported_device_new() dereferences edev immediately after calloc()
> without checking whether the allocation succeeded. An allocation failure
> therefore crashes the tool instead of allowing its caller to skip the
> device.
>
> Return NULL before accessing edev when calloc() fails.
>
> Fixes: 021aed845303 ("staging: usbip: userspace: migrate usbip_host_driver to libudev")
> Signed-off-by: Zhu Jun <zhujun2@cmss.chinamobile.com>
> ---
> tools/usb/usbip/libsrc/usbip_host_common.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/tools/usb/usbip/libsrc/usbip_host_common.c b/tools/usb/usbip/libsrc/usbip_host_common.c
> index 01599cb2fa7b..bec6c42e29c8 100644
> --- a/tools/usb/usbip/libsrc/usbip_host_common.c
> +++ b/tools/usb/usbip/libsrc/usbip_host_common.c
> @@ -71,6 +71,8 @@ struct usbip_exported_device *usbip_exported_device_new(
> int i;
>
> edev = calloc(1, sizeof(struct usbip_exported_device));
> + if (!edev)
> + return NULL;
How can calloc here ever fail?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-20 6:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-20 6:21 [PATCH] usbip: tools: Check allocation of exported devices Zhu Jun
2026-11-20 6:26 ` sashiko-bot
2026-11-20 6:39 ` Greg KH
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.