OSDN Git Service

usb: gadget: don't dereference g until after it has been null checked
authorColin Ian King <colin.king@canonical.com>
Tue, 14 Nov 2017 16:18:28 +0000 (16:18 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 3 Feb 2018 16:39:17 +0000 (17:39 +0100)
commit0479bc01767ff58170a2f1ae27e6b98f9dfa01b9
treebd52b0c539977d48ba513389339d8a9657f3ccea
parentaafb1a7eb0f73cf8bb59ed7cc6d29e19d4de49bc
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: b785ea7ce662 ("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@verizon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/gadget/composite.c