Linux USB
 help / color / mirror / Atom feed
* [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

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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox