Commit 944a6bc5 authored by Dan Carpenter's avatar Dan Carpenter Committed by Kleber Sacilotto de Souza

usb: gadget: Potential NULL dereference on allocation error

BugLink: https://bugs.launchpad.net/bugs/1822271

[ Upstream commit df28169e ]

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: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarStefan Bader <stefan.bader@canonical.com>
Acked-by: default avatarJuerg Haefliger <juerg.haefliger@canonical.com>
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
parent c2f169c8
...@@ -849,7 +849,7 @@ static struct usb_function *source_sink_alloc_func( ...@@ -849,7 +849,7 @@ static struct usb_function *source_sink_alloc_func(
ss = kzalloc(sizeof(*ss), GFP_KERNEL); ss = kzalloc(sizeof(*ss), GFP_KERNEL);
if (!ss) if (!ss)
return NULL; return ERR_PTR(-ENOMEM);
ss_opts = container_of(fi, struct f_ss_opts, func_inst); ss_opts = container_of(fi, struct f_ss_opts, func_inst);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment