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 3BED4C433FE for ; Wed, 24 Nov 2021 12:44:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344080AbhKXMrk (ORCPT ); Wed, 24 Nov 2021 07:47:40 -0500 Received: from mail.kernel.org ([198.145.29.99]:48796 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245130AbhKXMof (ORCPT ); Wed, 24 Nov 2021 07:44:35 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id E5C9161264; Wed, 24 Nov 2021 12:26:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1637756784; bh=/FX/HvPV1wbd/mWSfwnt+7LoURga2Z4SLtXXZalJUT8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zbC2G+Ec6mQ501nwYmDcnPJs+bTOoy/BISmFTyCBctGtZudLBy6/Lq2vgqdvdoWtO Q1PMTOupbwHZcW9NtsFC1P2yeH4pBDQOGbD7IJTuGeAqgdwAQ5e4tZacQbZg4aTJHe IKqSY25b2QxtvC4CNAkwdZDsKvkdGRs5A6bz5GQM= 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 204/251] usb: musb: tusb6010: check return value after calling platform_get_resource() Date: Wed, 24 Nov 2021 12:57:26 +0100 Message-Id: <20211124115717.353182091@linuxfoundation.org> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20211124115710.214900256@linuxfoundation.org> References: <20211124115710.214900256@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 7d7cb1c5ec808..9a7b5b2d7ccc7 100644 --- a/drivers/usb/musb/tusb6010.c +++ b/drivers/usb/musb/tusb6010.c @@ -1108,6 +1108,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