public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: hcd: fix the error check
@ 2020-08-20 12:20 Tang Bin
  2020-08-21 23:25 ` [usb] 33958ef53b: kmsg.ehci-pci#:#:#a.#:init#:#:#a.#fail kernel test robot
  2020-08-24  2:39 ` [PATCH] usb: hcd: fix the error check Peter Chen
  0 siblings, 2 replies; 3+ messages in thread
From: Tang Bin @ 2020-08-20 12:20 UTC (permalink / raw)
  To: gregkh; +Cc: linux-usb, linux-kernel, Tang Bin, Zhang Shengju

In the function usb_add_hcd(), usb_phy_roothub_alloc()
can return NULL in some cases, so IS_ERR() doesn't meet
the requirements. Thus fix it.
Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
Signed-off-by: Tang Bin <tangbin@cmss.chinamobile.com>
---
 drivers/usb/core/hcd.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index aa45840d8..b73a92ee1 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -2633,8 +2633,9 @@ int usb_add_hcd(struct usb_hcd *hcd,
 
 	if (!hcd->skip_phy_initialization && usb_hcd_is_primary_hcd(hcd)) {
 		hcd->phy_roothub = usb_phy_roothub_alloc(hcd->self.sysdev);
-		if (IS_ERR(hcd->phy_roothub))
-			return PTR_ERR(hcd->phy_roothub);
+		if (IS_ERR_OR_NULL(hcd->phy_roothub))
+			return hcd->phy_roothub ?
+					PTR_ERR(hcd->phy_roothub) : -ENODEV;
 
 		retval = usb_phy_roothub_init(hcd->phy_roothub);
 		if (retval)
-- 
2.20.1.windows.1




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

end of thread, other threads:[~2020-08-24  2:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-08-20 12:20 [PATCH] usb: hcd: fix the error check Tang Bin
2020-08-21 23:25 ` [usb] 33958ef53b: kmsg.ehci-pci#:#:#a.#:init#:#:#a.#fail kernel test robot
2020-08-24  2:39 ` [PATCH] usb: hcd: fix the error check Peter Chen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox