Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp148701pxa; Tue, 18 Aug 2020 19:13:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxI4k0SJ2GSUNswA+a137YZ0PMlfM/1c+tG0MHUyp3grTlZC1gYh1LNUIq8xLLC77LQsbP+ X-Received: by 2002:a17:906:89a:: with SMTP id n26mr22037554eje.363.1597803189227; Tue, 18 Aug 2020 19:13:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597803189; cv=none; d=google.com; s=arc-20160816; b=p3Ps8MCnL9xWq2Hzq1ZspozbJ6wZ0aCHp+D5NpL/Nblfu4xVab4oF8+vEs2hATzn2f Bu6WZi+2KlSekNmtIM/UHf2t/bv9s3e99x0yFe9ngphJeU6Dip23IT0A27OP+dREaUXQ 2ml64Uun9CP3+hMAhfoFTNPBOxayIzScSj6A2gCbpTQTtiejeyTXlin/+INNmBmpqH3f hLcX7mOlWxzwOndBzIRQ7r/r3CrOdyOpR3VId/Po2YcjXPh7LTvKhfIJZCqqua9h3bg2 djVflp2ZlXCnNq4zwnCqbYsoap6UYB5Z2ep9xCvxAR4LHbfmcVBv/DU+50F01jpScRgE wDPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=fZijQfeZPM4hiZKtSRdi97uh+DvPUEVxSfWGv7JO2Qk=; b=wByX68w2z3sHfVx9WhxFxjki10XeV6W8MZ+GckszacG52y0dg6r5QheuxldOmYBvzE wqKDZUpTZaJAT5Z2mLWTEC9jDktFWNyFVN4VvQEei6a4WB1N0aSkH5glucEMB6QT9z6P y6+huAFOSlZu/lHJp0AhcNoYHfSqKmphaHfun4hYjb2pLoiDMa+Un6XbolGQFJugYB0f 3vy32VOeXsOFh3hwzum4kevzheGyeRApZRlLHjqpIqqDaIhmWtqMaaxUfIIRdvJpxG3R /jFojEmgflchzWX2q0ZKS4XrNmoLJyeEI4eNsBcXld6SrgJ4UTvYKD7jH+sbd0LK/lXq tOLg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i24si13958366eja.529.2020.08.18.19.12.45; Tue, 18 Aug 2020 19:13:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726885AbgHSCFt (ORCPT + 99 others); Tue, 18 Aug 2020 22:05:49 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:53802 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726469AbgHSCFq (ORCPT ); Tue, 18 Aug 2020 22:05:46 -0400 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id A92CA3F694DDC345A29A; Wed, 19 Aug 2020 10:05:44 +0800 (CST) Received: from DESKTOP-C3MD9UG.china.huawei.com (10.174.177.253) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.487.0; Wed, 19 Aug 2020 10:05:33 +0800 From: Zhen Lei To: Oliver O'Halloran , Dan Williams , Vishal Verma , "Dave Jiang" , Ira Weiny , Markus Elfring , linux-nvdimm , linux-kernel CC: Zhen Lei Subject: [PATCH v2 2/4] libnvdimm: add sanity check for provider_name in of_pmem_region_probe() Date: Wed, 19 Aug 2020 10:05:01 +0800 Message-ID: <20200819020503.3079-3-thunder.leizhen@huawei.com> X-Mailer: git-send-email 2.26.0.windows.1 In-Reply-To: <20200819020503.3079-1-thunder.leizhen@huawei.com> References: <20200819020503.3079-1-thunder.leizhen@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.174.177.253] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org kstrdup() may return NULL because of no memory, check it. Fixes: 49bddc73d15c ("libnvdimm/of_pmem: Provide a unique name for bus provider") Signed-off-by: Zhen Lei --- drivers/nvdimm/of_pmem.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/nvdimm/of_pmem.c b/drivers/nvdimm/of_pmem.c index 1292ffca7b2ecc0..13c4c274ca6ea88 100644 --- a/drivers/nvdimm/of_pmem.c +++ b/drivers/nvdimm/of_pmem.c @@ -31,6 +31,11 @@ static int of_pmem_region_probe(struct platform_device *pdev) return -ENOMEM; priv->bus_desc.provider_name = kstrdup(pdev->name, GFP_KERNEL); + if (!priv->bus_desc.provider_name) { + kfree(priv); + return -ENOMEM; + } + priv->bus_desc.module = THIS_MODULE; priv->bus_desc.of_node = np; -- 1.8.3