Linux-USB Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] usb: gadget: udc: lpc32xx: don't dereference ep until it has been null checked
@ 2019-11-10 22:14 Colin King
  2019-11-10 22:53 ` Vladimir Zapolskiy
  0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2019-11-10 22:14 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman, Vladimir Zapolskiy,
	Sylvain Lemieux, Roland Stigge, Arnd Bergmann, linux-usb,
	linux-arm-kernel
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

The pointer ep is currently being dereferenced when initializing pointer
udc before ep is being null checked.  Fix this by only dereferencing
ep after it has been null checked.

Addresses-Coverity: ("Dereference before null check")
Fixes: 24a28e428351 ("USB: gadget driver for LPC32xx")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/usb/gadget/udc/lpc32xx_udc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/udc/lpc32xx_udc.c b/drivers/usb/gadget/udc/lpc32xx_udc.c
index d14b2bb3f67c..45b2a673ecba 100644
--- a/drivers/usb/gadget/udc/lpc32xx_udc.c
+++ b/drivers/usb/gadget/udc/lpc32xx_udc.c
@@ -1872,7 +1872,7 @@ static int lpc32xx_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req)
 static int lpc32xx_ep_set_halt(struct usb_ep *_ep, int value)
 {
 	struct lpc32xx_ep *ep = container_of(_ep, struct lpc32xx_ep, ep);
-	struct lpc32xx_udc *udc = ep->udc;
+	struct lpc32xx_udc *udc;
 	unsigned long flags;
 
 	if ((!ep) || (ep->hwep_num <= 1))
@@ -1882,6 +1882,7 @@ static int lpc32xx_ep_set_halt(struct usb_ep *_ep, int value)
 	if (ep->is_in)
 		return -EAGAIN;
 
+	udc = ep->udc;
 	spin_lock_irqsave(&udc->lock, flags);
 
 	if (value == 1) {
-- 
2.20.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] usb: gadget: udc: lpc32xx: don't dereference ep until it has been null checked
  2019-11-10 22:14 [PATCH] usb: gadget: udc: lpc32xx: don't dereference ep until it has been null checked Colin King
@ 2019-11-10 22:53 ` Vladimir Zapolskiy
  0 siblings, 0 replies; 2+ messages in thread
From: Vladimir Zapolskiy @ 2019-11-10 22:53 UTC (permalink / raw)
  To: Colin King, Felipe Balbi, Greg Kroah-Hartman, Sylvain Lemieux,
	Roland Stigge, Arnd Bergmann, linux-usb, linux-arm-kernel
  Cc: kernel-janitors, linux-kernel

On 11/11/2019 12:14 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> The pointer ep is currently being dereferenced when initializing pointer
> udc before ep is being null checked.  Fix this by only dereferencing
> ep after it has been null checked.
> 
> Addresses-Coverity: ("Dereference before null check")
> Fixes: 24a28e428351 ("USB: gadget driver for LPC32xx")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Acked-by: Vladimir Zapolskiy <vz@mleia.com>

--
Best wishes,
Vladimir

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-10 22:14 [PATCH] usb: gadget: udc: lpc32xx: don't dereference ep until it has been null checked Colin King
2019-11-10 22:53 ` Vladimir Zapolskiy

Linux-USB Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-usb/0 linux-usb/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-usb linux-usb/ https://lore.kernel.org/linux-usb \
		linux-usb@vger.kernel.org
	public-inbox-index linux-usb

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-usb


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git