usb: gadget: don't dereference g until after it has been null checked
[ Upstream commit b2fc059fa549fe6881d4c1f8d698b0f50bcd16ec ]
Avoid dereferencing pointer g until after g has been sanity null checked;
move the assignment of cdev much later when it is required into a more
local scope.
Detected by CoverityScan, CID#1222135 ("Dereference before null check")
Fixes: b785ea7ce6
("usb: gadget: composite: fix ep->maxburst initialization")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
8d594f9569
commit
380d05ee26
1 changed files with 5 additions and 2 deletions
|
@ -104,7 +104,6 @@ int config_ep_by_speed(struct usb_gadget *g,
|
||||||
struct usb_function *f,
|
struct usb_function *f,
|
||||||
struct usb_ep *_ep)
|
struct usb_ep *_ep)
|
||||||
{
|
{
|
||||||
struct usb_composite_dev *cdev = get_gadget_data(g);
|
|
||||||
struct usb_endpoint_descriptor *chosen_desc = NULL;
|
struct usb_endpoint_descriptor *chosen_desc = NULL;
|
||||||
struct usb_descriptor_header **speed_desc = NULL;
|
struct usb_descriptor_header **speed_desc = NULL;
|
||||||
|
|
||||||
|
@ -176,8 +175,12 @@ ep_found:
|
||||||
_ep->maxburst = comp_desc->bMaxBurst + 1;
|
_ep->maxburst = comp_desc->bMaxBurst + 1;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (comp_desc->bMaxBurst != 0)
|
if (comp_desc->bMaxBurst != 0) {
|
||||||
|
struct usb_composite_dev *cdev;
|
||||||
|
|
||||||
|
cdev = get_gadget_data(g);
|
||||||
ERROR(cdev, "ep0 bMaxBurst must be 0\n");
|
ERROR(cdev, "ep0 bMaxBurst must be 0\n");
|
||||||
|
}
|
||||||
_ep->maxburst = 1;
|
_ep->maxburst = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue