Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp2266148pxb; Fri, 8 Oct 2021 04:32:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJworoWSTIkdOY46IjAz82q1J9bM7G8X05VozmO9DnZppQwPK2Qod12KK2CBs5nbETqbB94d X-Received: by 2002:a17:90a:f0c4:: with SMTP id fa4mr11703736pjb.245.1633692750196; Fri, 08 Oct 2021 04:32:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633692750; cv=none; d=google.com; s=arc-20160816; b=jOAISvPPniAtKGTUPVMlmROUXetJ60GhE52WeJ/PtuIeSJ45EVw8IQtWsJYB8zJWfv fvHm7FEeP4sF1QUsc2OObztQQmxuO8L7tKvWr66YWTPKfdCwL4qj3zpKoT6ieMr2yWLj 02Tnc+gvhRHkqnBHjOAF6Em8ZkW4yjL29q3P1bBix2QBMSG6JtatRVpGJDh4TwAjsnQ/ vCLUoY5FxN7BtIwVbbFIkCstLilxQ6N1LF7uMnXX1u6i6xzMG6/HbKQfRJ1bClz+BmiW pf9ZSfMKdMr1n1E41ZFIpSanq7Kw6BBWEmg6yFkYwbtjL9RUzuKwf5Uqz5K1LyWWq6Jl 217w== 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=Mj5MsA7Ws6DlULDkUCi7dfdWsKkC2vJ5pT4mQVlBmzg=; b=o0e1Z+oCqCx6W0pVndnsjrSv6N2yKTcPnuTsBzk65cqcJHV8t7rwhTbamupjnpOQgY iXv0ru6pu+llDTTr9kZvnc1eo2sUcxUnt49ycjlcVHM4j7bVQru5t4rzl6IyVJxs0iKr CCzNoo/G0kV53sCITxn3PguMy7vIDhoODhUeU8ZadOVDvFEhk7H+44JzyrnwjMelm0eW 9qcYufBQME5SU9ULWWkh85uYczPKKeOg0ZuaxSQeIOOWdWL7gZfaLxvRjBodZb74f6Q8 QH2BwWMi1uz5yu/XtNUQhCLltemue2hCk3gaD8lCb5XNunibp0p56KDBeb4KhGhidmob tArA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=oYahWRlr; 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 v1si33620918pfb.272.2021.10.08.04.32.17; Fri, 08 Oct 2021 04:32:30 -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=oYahWRlr; 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 S240676AbhJHLdI (ORCPT + 99 others); Fri, 8 Oct 2021 07:33:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:59492 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240929AbhJHLbb (ORCPT ); Fri, 8 Oct 2021 07:31:31 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B6DF961056; Fri, 8 Oct 2021 11:29:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1633692567; bh=yhVH6Y5TeyZxusIfM3ydQf6bhlf+606vAiDW0DbitgA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oYahWRlrlYtEjCgqQerNrOeTPgblXkWh95DRIYYpaVw+C8JP9xEAB1OEvE3SVO5iZ lZFB/Y3T7+pIWtAVds64GqDvAWtgkkSA+yBxiXoDy/BMI4RJY81+ruJ+3FmazhKxdP RPmbUdbILzmD1AjKvo4tU71ap7PRqsmiouseV54M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yang Yingliang , Sasha Levin Subject: [PATCH 4.14 07/10] usb: dwc2: check return value after calling platform_get_resource() Date: Fri, 8 Oct 2021 13:27:48 +0200 Message-Id: <20211008112714.688232864@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211008112714.445637990@linuxfoundation.org> References: <20211008112714.445637990@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 ef7f3b013fcb..ba7528916da4 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -5229,6 +5229,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