From patchwork Thu Aug 20 12:20:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tang Bin X-Patchwork-Id: 11726227 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9FBA9138C for ; Thu, 20 Aug 2020 12:30:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 901CB207FB for ; Thu, 20 Aug 2020 12:30:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730003AbgHTMaB (ORCPT ); Thu, 20 Aug 2020 08:30:01 -0400 Received: from cmccmta2.chinamobile.com ([221.176.66.80]:12054 "EHLO cmccmta2.chinamobile.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729006AbgHTM36 (ORCPT ); Thu, 20 Aug 2020 08:29:58 -0400 X-Greylist: delayed 559 seconds by postgrey-1.27 at vger.kernel.org; Thu, 20 Aug 2020 08:29:56 EDT Received: from spf.mail.chinamobile.com (unknown[172.16.121.13]) by rmmx-syy-dmz-app08-12008 (RichMail) with SMTP id 2ee85f3e6a814ba-e3f62; Thu, 20 Aug 2020 20:20:18 +0800 (CST) X-RM-TRANSID: 2ee85f3e6a814ba-e3f62 X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG: 00000000 Received: from localhost.localdomain (unknown[223.112.105.130]) by rmsmtp-syy-appsvr07-12007 (RichMail) with SMTP id 2ee75f3e6a7f13e-2fed8; Thu, 20 Aug 2020 20:20:17 +0800 (CST) X-RM-TRANSID: 2ee75f3e6a7f13e-2fed8 From: Tang Bin To: gregkh@linuxfoundation.org Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Tang Bin , Zhang Shengju Subject: [PATCH] usb: hcd: fix the error check Date: Thu, 20 Aug 2020 20:20:38 +0800 Message-Id: <20200820122038.18704-1-tangbin@cmss.chinamobile.com> X-Mailer: git-send-email 2.20.1.windows.1 MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org 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 Signed-off-by: Tang Bin Reported-by: kernel test robot --- 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)