Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E0946C43217 for ; Wed, 24 Nov 2021 12:28:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343634AbhKXMbY (ORCPT ); Wed, 24 Nov 2021 07:31:24 -0500 Received: from mail.kernel.org ([198.145.29.99]:42144 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245167AbhKXMYo (ORCPT ); Wed, 24 Nov 2021 07:24:44 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id B850E6109E; Wed, 24 Nov 2021 12:15:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1637756124; bh=dcpl2f+8KBRt/uP+tn0OmypMvVqNkSS9gHGCM7XvEhA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jbBFGttSA66IAmfngsMq0+nPlD2/xOl2McfpV4JUfCX6iqPE7KZToWifIDt82oGId CVzoUJJtfWPsd7k8BeGF78GyVqmdJivuVn4TNllkPhj0S3OjnJ7Ng+PzKtMtVrH7Dk IgmAPs5kNRa9SAzHBpnMMg1F8Q65TAqOk4MDXdnM= 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.9 163/207] usb: musb: tusb6010: check return value after calling platform_get_resource() Date: Wed, 24 Nov 2021 12:57:14 +0100 Message-Id: <20211124115709.282638943@linuxfoundation.org> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20211124115703.941380739@linuxfoundation.org> References: <20211124115703.941380739@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 14651496a3de6807a17c310f63c894ea0c5d858e ] 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/20210915034925.2399823-1-yangyingliang@huawei.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/musb/tusb6010.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c index 7e9204fdba4a8..fb4239b5286fb 100644 --- a/drivers/usb/musb/tusb6010.c +++ b/drivers/usb/musb/tusb6010.c @@ -1120,6 +1120,11 @@ static int tusb_musb_init(struct musb *musb) /* dma address for async dma */ mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!mem) { + pr_debug("no async dma resource?\n"); + ret = -ENODEV; + goto done; + } musb->async = mem->start; /* dma address for sync dma */ -- 2.33.0