Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp449624iog; Mon, 13 Jun 2022 06:12:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzVToQIoxLxVWJYI3EovSXh0CEAYSsGgD2FsYrtoOpS1OFXX6ESZlMJegGyyMQ8O4d9QaCp X-Received: by 2002:a17:902:ec81:b0:163:3142:e0dd with SMTP id x1-20020a170902ec8100b001633142e0ddmr51929467plg.40.1655125930948; Mon, 13 Jun 2022 06:12:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655125930; cv=none; d=google.com; s=arc-20160816; b=XP3kjRy7ITKLAsk8okw+NGIDtuI/49CN4cqc6euJAOSt4kzzQhSLbti7wNC6AWEBOV 4v4/AneSx5EVpWSwTW4j0+XjCbDNC9J2LYvJtUZIhSX8YBDOld0vhPIBLZvz9mU+Up11 jmEuRTed6jKwViuUwk//XRUllq+pOP724ZJYjs5a1sQcrvUpczRlT7FidTUBilR5J1v4 7JdUiKTCCnObIWr7l7ixSqO7nIrx1klzY03sgJSvqV7qqxOhdAJSQjKgcFyf9hmvdzCF x/vwMvy2jeBprVeq5mfJINKthG5J9xKdhuOH89jJeVwhhKMWW7JJ7ZmA2bE/QjwOy/vL 4fug== 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=LjMT6a3Ur+f0VN8RErpzliX4P06ce6LYntq2B7TmNu8=; b=FUVvBFc7YKmtyDX7bNnyl1yZb1Hy0jH38Xte0npNKzsE449Tf7w0SbRim/1AWphcba bS4XYg10Dzffr4tLVWqsscxKnItkFX3JZdLnrPxNJhqTOsMUDYUUBfoiayxEsCdRQMPY sfAhsZ96D+dSmGwqr1MMXK4xQhnlf24Ite/mwMs/ZAXfoJlgdIzOUrQHX/FP2nrjafvu 9GRIpORxwMi03UyBRow+miDqiirQmNhmrvLKcjmBhteTDiFRHaTkIqFclYaxSO+mToKZ qKYYx7kPeNmONVfEcQao5fjnDO1oXaA2gOCWW+BduKnRGtEqgsiAvugjerEFFKnob4N+ WaUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vaw62Yit; 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 x126-20020a626384000000b0051b9771d617si8825747pfb.179.2022.06.13.06.11.58; Mon, 13 Jun 2022 06:12:10 -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=vaw62Yit; 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 S1344448AbiFMKbh (ORCPT + 99 others); Mon, 13 Jun 2022 06:31:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243834AbiFMKZi (ORCPT ); Mon, 13 Jun 2022 06:25:38 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5F39245A1; Mon, 13 Jun 2022 03:19:41 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 364D460AEA; Mon, 13 Jun 2022 10:19:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 44116C34114; Mon, 13 Jun 2022 10:19:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655115580; bh=X57FLXK/sZrQYkPEBhG57IZ4/8Z2UlPgRRxegroWD3o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vaw62YitBEO/75XEtckkkuZnAvIRjqI1kWDhMm878yD4cOUAQEpaTD5b9vg1+uTyh AuuMnEIrjDLtqjIpCBfPPen69c+mbBWnggxgzvhX9aDLkgP/VYm23sZ6W9wUP8PDHv P3obf7nJyuhwglO6jA0Bl1cyniSDgT4Y/2bXt2xk= 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.9 115/167] rtc: mt6397: check return value after calling platform_get_resource() Date: Mon, 13 Jun 2022 12:09:49 +0200 Message-Id: <20220613094907.693616948@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094840.720778945@linuxfoundation.org> References: <20220613094840.720778945@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 494a7fbd512b..7e37ec7c8e02 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