Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: gadget: Potential NULL dereference on allocation error

The source_sink_alloc_func() function is supposed to return error
pointers on error. The function is called from usb_get_function() which
doesn't check for NULL returns so it would result in an Oops.

Of course, in the current kernel, small allocations always succeed so
this doesn't affect runtime.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>

authored by

Dan Carpenter and committed by
Felipe Balbi
df28169e 88b1bb1f

+1 -1
+1 -1
drivers/usb/gadget/function/f_sourcesink.c
··· 838 838 839 839 ss = kzalloc(sizeof(*ss), GFP_KERNEL); 840 840 if (!ss) 841 - return NULL; 841 + return ERR_PTR(-ENOMEM); 842 842 843 843 ss_opts = container_of(fi, struct f_ss_opts, func_inst); 844 844