From patchwork Mon Nov 14 02:01:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hui Tang X-Patchwork-Id: 19513 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1920789wru; Sun, 13 Nov 2022 18:14:30 -0800 (PST) X-Google-Smtp-Source: AA0mqf6CZv/MtLPSTr8zDLVxlFfvDnwEf3av6jRYFxPD5ip+DE0W/3neZN0TcM8UPYCicuODviNf X-Received: by 2002:a17:902:e395:b0:17f:809b:7f85 with SMTP id g21-20020a170902e39500b0017f809b7f85mr11767187ple.21.1668392069964; Sun, 13 Nov 2022 18:14:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668392069; cv=none; d=google.com; s=arc-20160816; b=h+qBd9tjbKrua/h/80hr3IlHueKfFH2ZaoHARuzRUkqxmgl/ldvAr+h9YfSEbpGo6R hTmja0/vZr2T/giYp1uSU2wx6V8e98ncF6tMh3KTevmhtecbCzxIgqxyo/RzL+tqnCW6 EQTVv9CD+VkuABxMDOl9LDNtmLvL3TZ/EHVgUeQgDoEYvZXkMCoaxwLdsstkbebqvCJX Ap+xHo6Q2+2O8C7BqHLYou2Zv+1gFZKk69N1v0KppRB0CGUt1GwSFD1PyDl1ez47DS73 rRnpjmKHS6RNSBRQ5I5iaYhmDBB9PxshXOKzpgqK21Ec+upz7J5URr29eyMTvDoXq4bZ Rl1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=m/QginMEYwvUy6Hffx+RB7KaRAfC3TNdC6R4n8Df6fc=; b=yJLJyEeg5I5ecitaFtYEYNpiWEVaJ3YE5n0pWulhYfVXh5STmT7HNyIP0JoNIQ0dBl araAGT3s49KpvHMJyyXT8jE/Rqfdz7WgtyCIv3LGm6Gjytv8xh0/uk2YsnkckyCHSpw+ M7dWu3GA9QVUUpSErUKd0gqlfMILHVb/XZJn/4l237LJK+FMCpwEkgvSziL2zJyj/Nhm cmEYpndW28b3NcO8orxNwh3YHo9UtEsYzkoJqJvowNq2pYiaqnbfDUZAFOi3Hd9JYWNO 7L1G+HSRZU5UIYkcIO6QMZPkg+c1tQx5LhFvOTfie6RN8+bTvemxVZLT6mnfqXcaNXa0 18HA== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r13-20020a63e50d000000b00448c6dd8fa9si8275927pgh.444.2022.11.13.18.14.16; Sun, 13 Nov 2022 18:14:29 -0800 (PST) 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 S235495AbiKNCFL (ORCPT + 99 others); Sun, 13 Nov 2022 21:05:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229692AbiKNCFI (ORCPT ); Sun, 13 Nov 2022 21:05:08 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C18ABDFA1 for ; Sun, 13 Nov 2022 18:04:56 -0800 (PST) Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4N9XgG1Nd5zHvrl; Mon, 14 Nov 2022 10:04:26 +0800 (CST) Received: from kwepemm600005.china.huawei.com (7.193.23.191) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 14 Nov 2022 10:04:54 +0800 Received: from ubuntu1804.huawei.com (10.67.175.30) by kwepemm600005.china.huawei.com (7.193.23.191) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 14 Nov 2022 10:04:53 +0800 From: Hui Tang To: , , , CC: , , , Subject: [PATCH] mtd: lpddr2_nvm: i2c: mux: reg: Fix possible null-ptr-deref Date: Mon, 14 Nov 2022 10:01:41 +0800 Message-ID: <20221114020141.28138-1-tanghui20@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Originating-IP: [10.67.175.30] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemm600005.china.huawei.com (7.193.23.191) 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749435883175445219?= X-GMAIL-MSGID: =?utf-8?q?1749435883175445219?= It will cause null-ptr-deref when resource_size(add_range) invoked, if platform_get_resource() returns NULL. Fixes: 96ba9dd65788 ("mtd: lpddr: add driver for LPDDR2-NVM PCM memories") Signed-off-by: Hui Tang --- drivers/mtd/lpddr/lpddr2_nvm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/mtd/lpddr/lpddr2_nvm.c b/drivers/mtd/lpddr/lpddr2_nvm.c index 367e2d906de0..cf8e86eb4b2c 100644 --- a/drivers/mtd/lpddr/lpddr2_nvm.c +++ b/drivers/mtd/lpddr/lpddr2_nvm.c @@ -433,6 +433,8 @@ static int lpddr2_nvm_probe(struct platform_device *pdev) /* lpddr2_nvm address range */ add_range = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (IS_ERR(add_range)) + return -ENODEV; /* Populate map_info data structure */ *map = (struct map_info) {