Skip to content

Commit

Permalink
usb: gadget: Potential NULL dereference on allocation error
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Dan Carpenter authored and Felipe Balbi committed Jan 14, 2019
1 parent 88b1bb1 commit df28169
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/usb/gadget/function/f_sourcesink.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit df28169

Please sign in to comment.