[PATCH] media: usb: siano: don't set URB_FREE_BUFFER flag

From: Tetsuo Handa

Date: Fri Apr 17 2026 - 10:37:41 EST


syzbot is reporting invalid free at usb_free_urb(), for

smscore_register_device() allocates all buffers at once as an array

smscore_createbuffer() maps each element in the array to cb->p

usb_fill_bulk_urb() assigns urb->transfer_buffer using cb->p
which may point to a non-head element in the array

URB_FREE_BUFFER causes usb_free_urb() to free urb->transfer_buffer
which may point to a non-head element in the array

The urb->transfer_buffer must point to an address returned by kmalloc()
family if URB_FREE_BUFFER flag is set. But since the urb->transfer_buffer
allocation strategy for this module is to allocate buffers upon device
registration and free buffers upon device unregistration, we should
avoid setting URB_FREE_BUFFER flag. Otherwise, double free or invalid
free will happen.

Reported-by: syzbot+b466336413a1fba398a5@xxxxxxxxxxxxxxxxxxxxxxxxx
Closes: https://syzkaller.appspot.com/bug?extid=b466336413a1fba398a5
Fixes: 564246fd3ff4 ("media: siano: Fix coherent memory allocation failure on arm64")
Signed-off-by: Tetsuo Handa <penguin-kernel@xxxxxxxxxxxxxxxxxxx>
---
I found that the same change was proposed at
https://lore.kernel.org/all/20250522140048.2811356-1-n.zhandarovich@xxxxxxxxxx/T/
after I wrote this patch.
If nobody is using this module, we should consider removing this module?

drivers/media/usb/siano/smsusb.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/drivers/media/usb/siano/smsusb.c b/drivers/media/usb/siano/smsusb.c
index 0fdc2e0950b7..8140dc0c8b7d 100644
--- a/drivers/media/usb/siano/smsusb.c
+++ b/drivers/media/usb/siano/smsusb.c
@@ -168,7 +168,6 @@ static int smsusb_submit_urb(struct smsusb_device_t *dev,
smsusb_onresponse,
surb
);
- surb->urb->transfer_flags |= URB_FREE_BUFFER;

return usb_submit_urb(surb->urb, GFP_ATOMIC);
}
--
2.47.3