lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1652861570-102489-1-git-send-email-lyz_cs@pku.edu.cn>
Date:   Wed, 18 May 2022 01:12:50 -0700
From:   Yongzhi Liu <lyz_cs@....edu.cn>
To:     peter.chen@...nel.org, pawell@...ence.com, rogerq@...nel.org,
        a-govindraju@...com, gregkh@...uxfoundation.org,
        felipe.balbi@...ux.intel.com
Cc:     linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org,
        fuyq@....pku.edu.cn, Yongzhi Liu <lyz_cs@....edu.cn>
Subject: [PATCH] usb: cdns3:  Fix potential dereference of NULL pointer

The return value of cdns3_gadget_ep_alloc_request()
needs to be checked to avoid use of NULL pointer
in case of an allocation failure.

Fixes: 7733f6c32e36f ("usb: cdns3: Add Cadence USB3 DRD Driver")

Signed-off-by: Yongzhi Liu <lyz_cs@....edu.cn>
---
 drivers/usb/cdns3/cdns3-gadget.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/cdns3/cdns3-gadget.c b/drivers/usb/cdns3/cdns3-gadget.c
index 5d8c982..7be328e 100644
--- a/drivers/usb/cdns3/cdns3-gadget.c
+++ b/drivers/usb/cdns3/cdns3-gadget.c
@@ -2568,6 +2568,10 @@ static int cdns3_gadget_ep_queue(struct usb_ep *ep, struct usb_request *request,
 		struct cdns3_request *priv_req;
 
 		zlp_request = cdns3_gadget_ep_alloc_request(ep, GFP_ATOMIC);
+		if (!zlp_request) {
+			ret = -ENOMEM;
+			goto err;
+		}
 		zlp_request->buf = priv_dev->zlp_buf;
 		zlp_request->length = 0;
 
@@ -2578,7 +2582,7 @@ static int cdns3_gadget_ep_queue(struct usb_ep *ep, struct usb_request *request,
 			priv_ep->name);
 		ret = __cdns3_gadget_ep_queue(ep, zlp_request, gfp_flags);
 	}
-
+err:
 	spin_unlock_irqrestore(&priv_dev->lock, flags);
 	return ret;
 }
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ