Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp2268138pxb; Fri, 8 Oct 2021 04:35:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxaNFrmVhjl6qJGI+kzKym796LbO+0u00mGdcrYkzf14RFWQJvYY+VRLgHqyyzpGAdPHdHG X-Received: by 2002:a17:90a:db51:: with SMTP id u17mr6046524pjx.171.1633692902756; Fri, 08 Oct 2021 04:35:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633692902; cv=none; d=google.com; s=arc-20160816; b=K9hd3fS2p5pdbzE1nMfAuZBlIrKHH6k2uf4vxHP1GSDEVo5rKfIpbsdjcuilg8FUkZ CU70ELATiCsJA6Z/bQffHORnTC2q3zKxBwU3WYzdsRDj7GZEaWmoYmmnsozTV/bLjVLH iGfjXPj8dHj8RbnbSGJD5D+c/dzJGLj68qmhozPTSKjY6HYruY73CGyLiDRoBPKYJWCB DQMZ/FcW3tnuXkk2z5sHR53F1EqF2cwewRBkaUhu1LZyfueoarYn+lrzCBVFE9kJuw7+ hSOMDRET0JrmC3UF2FHZP3eYWu74zjv/PUQM9+PSyJJQ6ZXBnkn2tSL4n3FeuEo3bIBB /7UA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=dcUBdK0WrEGuXVPQu2me4YCN9KC6jINoXd0Bshsx7Q4=; b=h78R8o8T7xl+wv+hUIl33Wef4aE+xYb6Px0l0h7CF/dIyuDhXzo6Dd6iz8uRYuWttB GHVmgJLC9M7uJTtcQBQ1jL8JkW+aIQkJKZnTFEaXQn8k2jqJmCklW1Me5wnDTC4KCt0R SO79sycnVB8cL/G+pBp3eb4BsYxGLNECmfhAT0+l8J4f9vGQInO2cYOMsDeb7a//DP/O ADdx9O3hVGfKyfLxWi+Pau9XBezN6N568J+nOFpilQWJdK8hPl0o5Yhui8NuPIEPIb9R +A1ZW8OfZcOyHVSuw6SQLlEOy0vMlz61jvT1Am8Dt1Wkew08ujwnQT5Ke6AJ7lBsMTVO yA9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BM9KgvnN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i24si2746745pgl.474.2021.10.08.04.34.50; Fri, 08 Oct 2021 04:35:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BM9KgvnN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241440AbhJHLey (ORCPT + 99 others); Fri, 8 Oct 2021 07:34:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:59392 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241256AbhJHLcz (ORCPT ); Fri, 8 Oct 2021 07:32:55 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 13DDF61038; Fri, 8 Oct 2021 11:30:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1633692632; bh=2iabheF+uJp+Z+9OHfVQDR7iplTtXBfjB0lBc0ON6wg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BM9KgvnNDeaQuxSSwEPhcM6i9PyRu4NhLoioACcU4sJA9fvd9dkjVSCLN5g7cadzK hSMgaJRnsL/I+Q5m1UwOTOu/Hj/LSTHDbGgd6Ru7BfTiHUxoFYSAunuumUVqqrwNj/ VDdFbdjbUGjuM/q0wQeNIvmvh+GpI3BcXEsFdx+M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yang Yingliang , Sasha Levin Subject: [PATCH 5.4 07/16] usb: dwc2: check return value after calling platform_get_resource() Date: Fri, 8 Oct 2021 13:27:57 +0200 Message-Id: <20211008112715.709403391@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211008112715.444305067@linuxfoundation.org> References: <20211008112715.444305067@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yang Yingliang [ Upstream commit 856e6e8e0f9300befa87dde09edb578555c99a82 ] It will cause null-ptr-deref if platform_get_resource() returns NULL, we need check the return value. Signed-off-by: Yang Yingliang Link: https://lore.kernel.org/r/20210831084236.1359677-1-yangyingliang@huawei.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/dwc2/hcd.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index f29fbadb0548..78329d0e9af0 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -5074,6 +5074,10 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg) hcd->has_tt = 1; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) { + retval = -EINVAL; + goto error1; + } hcd->rsrc_start = res->start; hcd->rsrc_len = resource_size(res); -- 2.33.0