Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp2169711iob; Thu, 5 May 2022 17:53:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwOktCzPuuyIydr2pVQOnXnd9zp7jkdwHw56jaKEJP+zGE3j1fekEoqGanplE9JSmy8gM53 X-Received: by 2002:a17:902:8644:b0:15a:3b4a:538a with SMTP id y4-20020a170902864400b0015a3b4a538amr883125plt.146.1651798379921; Thu, 05 May 2022 17:52:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651798379; cv=none; d=google.com; s=arc-20160816; b=TwBGiXBrISGvoArA98rQR1V50cZvPo56gOKrYDPIN3tuCuJVkbC4FEWk61FeEqquxF 1MjOUegDaY5bRo2OiKPQy1YkNIgT9u+gkBFCh93h/BHLXmkc328f1V8V75JnD3qlJte5 K9iiFJqDyI9NOL7nZYprbqYab1pLrMmtmE+6IVFeOe35CzYtByEKU7nAMGe6jG4yoa5P qvm1nvLFcutlrTsxRzdpHMCGNh3NV3CRPHbVN3yJQSMAB+rnp8QOcyZJKdpUFTj1Den/ ld1VSDUw+XtjsRlDcVoluAmdf4uKPA118GVzeNlkecAt/8aa/GMuByvdFbkzxZyS7kWB Jy6w== 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 :message-id:date:subject:cc:to:from; bh=SGbOfr+nCJuv4uf/wZGF/1rgJwiflFHh+mYQZ0DZbu8=; b=NGZ+F4FNmVFaTc3g5Q6FcC8Q80NASxSy78S0XLpGTgYeTVSTAOVvdGdcIt9OB37Cxe a/oRmQZNFqZkrXLejbfdJIbhTj5XilrY+/0P/fPU/zzlsW8a1NBOAv7Gq9eSuIuqdDAq eQ+xLzSOg0LCQm0t0QbfscD0pwmjqTZ76D3q9wUG5It4QN44tKHm7qeDc26GFQfnFY6p Dc9yGFrvi+IFpTU3GG9oI9MVtpQUCOPktPDVHRHqiCQJ8txboLTr3WR2CgcHAvCc4Sk9 l7HnicgNiIk20R1gh4fvCOwXKlyY65BBMgCC1oLFyai/d7XcD2QbNAPC42fER0UsCj/n 0Xqw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z29-20020a63191d000000b003c63fd7c0b1si848758pgl.807.2022.05.05.17.52.44; Thu, 05 May 2022 17:52:59 -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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377290AbiEEMmp (ORCPT + 99 others); Thu, 5 May 2022 08:42:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376382AbiEEMmk (ORCPT ); Thu, 5 May 2022 08:42:40 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC363554AC; Thu, 5 May 2022 05:39:00 -0700 (PDT) Received: from dggpemm500022.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4KvCqM4BhTzGpTN; Thu, 5 May 2022 20:36:15 +0800 (CST) Received: from dggpemm500007.china.huawei.com (7.185.36.183) by dggpemm500022.china.huawei.com (7.185.36.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 5 May 2022 20:38:59 +0800 Received: from huawei.com (10.175.103.91) by dggpemm500007.china.huawei.com (7.185.36.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 5 May 2022 20:38:58 +0800 From: Yang Yingliang To: , , , CC: , , , , Subject: [PATCH] rtc: mt6397: check return value after calling platform_get_resource() Date: Thu, 5 May 2022 20:50:43 +0800 Message-ID: <20220505125043.1594771-1-yangyingliang@huawei.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.103.91] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm500007.china.huawei.com (7.185.36.183) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, 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 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 --- 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 80dc479a6ff0..1d297af80f87 100644 --- a/drivers/rtc/rtc-mt6397.c +++ b/drivers/rtc/rtc-mt6397.c @@ -269,6 +269,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; rtc->data = of_device_get_match_data(&pdev->dev); -- 2.25.1