]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
usb: gadget: Potential NULL dereference on allocation error
authorDan Carpenter <dan.carpenter@oracle.com>
Fri, 21 Dec 2018 20:42:52 +0000 (23:42 +0300)
committerFelipe Balbi <felipe.balbi@linux.intel.com>
Mon, 14 Jan 2019 08:29:55 +0000 (10:29 +0200)
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>
drivers/usb/gadget/function/f_sourcesink.c

index 9cdef108fb1b3da5581c99c8251903702b04c6a8..ed68a4860b7d8702e1a8fd9cca40b04b5065a4ce 100644 (file)
@@ -838,7 +838,7 @@ static struct usb_function *source_sink_alloc_func(
 
        ss = kzalloc(sizeof(*ss), GFP_KERNEL);
        if (!ss)
-               return NULL;
+               return ERR_PTR(-ENOMEM);
 
        ss_opts =  container_of(fi, struct f_ss_opts, func_inst);