Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp583864iog; Mon, 13 Jun 2022 08:35:14 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sbi35BoMmJrpxH3I6csWCrRumWtvux8BPl37GVOIq3TVAWyZNrM1HlDYoUK0NkfJcKhZPB X-Received: by 2002:a05:6402:2548:b0:42d:dd95:5bfe with SMTP id l8-20020a056402254800b0042ddd955bfemr302444edb.285.1655134514361; Mon, 13 Jun 2022 08:35:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655134514; cv=none; d=google.com; s=arc-20160816; b=Fb3fNtGeMQ/X2eJZ0UlRZfn1pivYrb9f+wt2lQTx13BxOF3IAcguSS/c0t2LRaqNWD YqZYyd0e/WxGAlKyd7KHRCueOcLOv1e4K1Yl9opXkSdnbXNu6Hy5tSDp1+XAe/4KUL0u 6b8pJQfkgOgE4PVnkIzkLakOtF6tNSzRjHnlOGc/bTItQTZwS7b/swxiJ37mwVMogq5/ keggRLmpAtIMoyc4WHiLKJEY0XkZOZVcKXPvYxADkbAcWDWsC6uCXmNRNHo92aPiyguk v/1v8PGq3asbLqA+G3tjGN5EBg/13i0Hzu6wIw202LsYIirBihKQFnhrBYaGvjxi0gZT HEVQ== 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=UOKeGwDYp3zuHCmDvBFlvUjWC3YyjS0tN0w58QgSOyI=; b=FS2IGvEE1XvutipS8FpOhOhBB6csIivquBxdlk20XMluLowJCrxH+Y8ttB7zdEVh5o 5V9BFCHi/j+F4bKvdyJjS/dNNTcdsxz9/wsxj/5oprY0C2V2ZgJpClA7PwTD3fXJkcnS STzWfP56l3lyAu5O17KI9Hs7mOmifwH+vI+Cig4b1gRz+SEifKGVLIaGlqbCmBetBRjV FDZk3zZKn8EUpEvWvPI+Z+mf9t8ekGEAq4s/vFHDLWBOyOKTPsCWOqI6RzCeLoXD1MZ1 IXuTbBrxhn4N4ZYYep89qsKtrp6mKcWqaxtp3GVrNz1HhU3IU+VYaiWZ8ILxqxnra0Rf 8EVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Ja1aqyid; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r13-20020a05640251cd00b0042dfb99b7fesi9635725edd.34.2022.06.13.08.34.49; Mon, 13 Jun 2022 08:35:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Ja1aqyid; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S1349735AbiFMLAk (ORCPT + 99 others); Mon, 13 Jun 2022 07:00:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350193AbiFMKyo (ORCPT ); Mon, 13 Jun 2022 06:54:44 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A099DDFF6; Mon, 13 Jun 2022 03:30:06 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 5FE85B80E59; Mon, 13 Jun 2022 10:30:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CC1C5C34114; Mon, 13 Jun 2022 10:30:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655116204; bh=hmzvgPynRH9//Z3IV58dQ/nNb/qxrzbVr8+lfON61+4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ja1aqyidKBYoFl7kBbPRnSYhTGXs+En7Vb4w88/fEGxZFFoQ4aAXAz3w/TkP+1Aoa xJFy6GljCUi5K2w8ntY1o/EJBsy+cHZWzvX7SANgRFJ25OTxdb/B1usJqpORQVvaao UD3eyOt6mCQjqnOi+5YMsHefrz5v+Nr2+h5RINmg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yang Yingliang , AngeloGioacchino Del Regno , Alexandre Belloni , Sasha Levin Subject: [PATCH 4.14 150/218] rtc: mt6397: check return value after calling platform_get_resource() Date: Mon, 13 Jun 2022 12:10:08 +0200 Message-Id: <20220613094925.140006180@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094908.257446132@linuxfoundation.org> References: <20220613094908.257446132@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yang Yingliang [ Upstream commit d3b43eb505bffb8e4cdf6800c15660c001553fe6 ] It will cause null-ptr-deref if platform_get_resource() returns NULL, we need check the return value. Fixes: fc2979118f3f ("rtc: mediatek: Add MT6397 RTC driver") Signed-off-by: Yang Yingliang Reviewed-by: AngeloGioacchino Del Regno Signed-off-by: Alexandre Belloni Link: https://lore.kernel.org/r/20220505125043.1594771-1-yangyingliang@huawei.com Signed-off-by: Sasha Levin --- drivers/rtc/rtc-mt6397.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/rtc/rtc-mt6397.c b/drivers/rtc/rtc-mt6397.c index c696d9186451..4fdd96f71e11 100644 --- a/drivers/rtc/rtc-mt6397.c +++ b/drivers/rtc/rtc-mt6397.c @@ -339,6 +339,8 @@ static int mtk_rtc_probe(struct platform_device *pdev) return -ENOMEM; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) + return -EINVAL; rtc->addr_base = res->start; res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); -- 2.35.1