Re: [PATCH] usb: gadget: f_mass_storage: fix null pointer dereference in fsg_common_set_num_buffers()
Jeffin Philip <[email protected]>
| Newsgroups | org.kernel.vger.linux-usb,org.kernel.vger.linux-kernel,org.kernel.vger.stable |
|---|---|
| Message-ID | <[email protected]> |
On Mon, 17 Aug 2026 13:10:27 +0200, Greg KH wrote: >But that is probably a bad idea, right? Shouldn't we fix that error >first? Thanks for the review. Don't quite understand what I need to fix here (respectfully), should we harden the buffhds null check to include ZERO_SIZE_PTRs too, something like this should suffice?: diff --git a/drivers/usb/gadget/function/f_mass_storage.c b/drivers/usb/gadget/function/f_mass_storage.c index 640d3bcb7bf0..98643d53cc7a 100644 --- a/drivers/usb/gadget/function/f_mass_storage.c +++ b/drivers/usb/gadget/function/f_mass_storage.c @@ -2747,11 +2747,11 @@ int fsg_common_set_num_buffers(struct fsg_common *common, unsigned int n) struct fsg_buffhd *bh, *buffhds; int i; buffhds = kzalloc_objs(*buffhds, n); - if (!buffhds) + if (ZERO_OR_NULL_PTR(buffhds)) return -ENOMEM; /* Data buffers cyclic list */ Thanks, Jeffin.