[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220629055605.102425-1-mailmesebin00@gmail.com>
Date: Wed, 29 Jun 2022 11:26:05 +0530
From: SebinSebastian <mailmesebin00@...il.com>
To: unlisted-recipients:; (no To-header on input)
Cc: mailmesebin00@...il.com, skhan@...uxfoundation.org,
Neal Liu <neal_liu@...eedtech.com>,
Felipe Balbi <balbi@...nel.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Joel Stanley <joel@....id.au>,
Andrew Jeffery <andrew@...id.au>,
linux-aspeed@...ts.ozlabs.org, linux-usb@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: [PATCH-next] usb: gadget: dereference before null check
From: Sebin Sebastian <mailmesebin00@...il.com>
Fix coverity warning dereferencing before null check. _ep and desc is
deferenced on all paths until the check for null. Move the
initilizations after the check for null.
Coverity issue: 1518209
Signed-off-by: Sebin Sebastian <mailmesebin00@...il.com>
---
drivers/usb/gadget/udc/aspeed_udc.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/usb/gadget/udc/aspeed_udc.c b/drivers/usb/gadget/udc/aspeed_udc.c
index d75a4e070bf7..4f158030e2cc 100644
--- a/drivers/usb/gadget/udc/aspeed_udc.c
+++ b/drivers/usb/gadget/udc/aspeed_udc.c
@@ -341,10 +341,6 @@ static void ast_udc_stop_activity(struct ast_udc_dev *udc)
static int ast_udc_ep_enable(struct usb_ep *_ep,
const struct usb_endpoint_descriptor *desc)
{
- u16 maxpacket = usb_endpoint_maxp(desc);
- struct ast_udc_ep *ep = to_ast_ep(_ep);
- struct ast_udc_dev *udc = ep->udc;
- u8 epnum = usb_endpoint_num(desc);
unsigned long flags;
u32 ep_conf = 0;
u8 dir_in;
@@ -355,6 +351,12 @@ static int ast_udc_ep_enable(struct usb_ep *_ep,
EP_DBG(ep, "Failed, invalid EP enable param\n");
return -EINVAL;
}
+
+ u16 maxpacket = usb_endpoint_maxp(desc);
+ struct ast_udc_ep *ep = to_ast_ep(_ep);
+ struct ast_udc_dev *udc = ep->udc;
+ u8 epnum = usb_endpoint_num(desc);
+
if (!udc->driver) {
EP_DBG(ep, "bogus device state\n");
--
2.34.1
Powered by blists - more mailing lists