usb: gadget: lpc32xx_udc: don't dereference ep pointer before null check
authorColin Ian King <colin.king@canonical.com>
Thu, 21 May 2020 15:13:00 +0000 (16:13 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 24 Jun 2020 15:50:32 +0000 (17:50 +0200)
commit51ad579d64dd1c6c308d7c915da6a8f9c90355d7
treed426949cbc51a8c711741b86ca9dc65501c5bc98
parent4a8c5f25c6bcf31fb06e9ff3ee0b573c723fdea3
usb: gadget: lpc32xx_udc: don't dereference ep pointer before null check

[ Upstream commit eafa80041645cd7604c4357b1a0cd4a3c81f2227 ]

Currently pointer ep is being dereferenced before it is null checked
leading to a null pointer dereference issue.  Fix this by only assigning
pointer udc once ep is known to be not null.  Also remove a debug
message that requires a valid udc which may not be possible at that
point.

Addresses-Coverity: ("Dereference before null check")
Fixes: 24a28e428351 ("USB: gadget driver for LPC32xx")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Felipe Balbi <balbi@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/usb/gadget/udc/lpc32xx_udc.c