Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp539438imu; Wed, 23 Jan 2019 00:55:57 -0800 (PST) X-Google-Smtp-Source: ALg8bN4FTFFvoCgNQ0A1em5crGhfKhMJzCB3sqs6X4uXS3vNJkhR3/8EqqSFD228nqByczMn/Lj4 X-Received: by 2002:a62:11c7:: with SMTP id 68mr1304012pfr.21.1548233757781; Wed, 23 Jan 2019 00:55:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548233757; cv=none; d=google.com; s=arc-20160816; b=LRI+sOcimfOvmGutL893wpd86XYBlYNkJg572uWM0FvvJzlFdaDR2XoIvSpkYbqUuT YRCeWthCrUBCa12n4Ntc3zFhndw1e+uNV1csX2q1zczJKiffQPr/Az2xfHmMXQAFUM21 WCBGx5GQ9EGQQ4tRb6vn9z37mORCwAKsLgw2u2pVAZsmLGIblHXP8QLBrjaXWKida2bt rPtdF2Z5blRhvwJjj59S77bMzz8nCB7drPt8tIKTVd7RRkiKOaGYCul87F1XcOwAcDVO ANhRCWo0LqUpK2tT8uDVenCVPg7pEA6DUI+lXKnzwPBA8OrcK3Y6AnbznzpN6trDtkVH cUhA== 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:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject; bh=aAcNPwxpVbJEPlJ4q8lSvtjRW1iR/n7AnonOAJhH1PA=; b=xUHxA1Wk/UykWLU07nP+bJnd4lkCBm4EO99kp0IgwuteTpR8edU26+LjUoy3kprkcV Lrs4gTZ20TLF27X6wQdIYyzmNgT3/N84Q9IR3Uf54Otwbgl/1qxnfVSQwCLMC9/avnaM uY7t4E5wAIKIw4wKUWikUyH9Sz6MVgT31Zwy11lL+NhtymKFcXqYmivlFprgtCOMFXY/ pI4XspZNYXenCUgkMB3yim7Ww4yz97pwFnOGy/TtJLKfF2m24ZaJ5D3JGoxBZyAnTODn uiQysfBu81ngCSYl+ojuuwKQEf6dw2G3TMWLC9AROHNsnncWKWtF2qm6BF0sojU2EqEJ iWNg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bj2si18103308plb.27.2019.01.23.00.55.42; Wed, 23 Jan 2019 00:55:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727160AbfAWIyI (ORCPT + 99 others); Wed, 23 Jan 2019 03:54:08 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:2217 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726322AbfAWIyI (ORCPT ); Wed, 23 Jan 2019 03:54:08 -0500 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 69830D656A2878CC6A8C; Wed, 23 Jan 2019 16:54:06 +0800 (CST) Received: from [127.0.0.1] (10.177.31.96) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.408.0; Wed, 23 Jan 2019 16:54:05 +0800 Subject: Re: [PATCH -next] mtd: docg3: Fix a possible memory leak of mtd->name To: Boris Brezillon References: <20190123065943.5868-1-yuehaibing@huawei.com> <20190123094644.23f27c3e@bbrezillon> CC: , , , , , , From: YueHaibing Message-ID: Date: Wed, 23 Jan 2019 16:54:04 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <20190123094644.23f27c3e@bbrezillon> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.31.96] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019/1/23 16:46, Boris Brezillon wrote: > On Wed, 23 Jan 2019 14:59:43 +0800 > YueHaibing wrote: > >> In case DOC_CHIPID_G3, mtd->name should be freed in the >> err handling path, which is alloced by kasprintf. >> >> Fixes: ae9d4934b2d7 ("mtd: docg3: add multiple floor support") >> Signed-off-by: YueHaibing >> --- >> drivers/mtd/devices/docg3.c | 1 + >> 1 file changed, 1 insertion(+) >> >> diff --git a/drivers/mtd/devices/docg3.c b/drivers/mtd/devices/docg3.c >> index 60ddc38..cbd25f9 100644 >> --- a/drivers/mtd/devices/docg3.c >> +++ b/drivers/mtd/devices/docg3.c >> @@ -1867,6 +1867,7 @@ doc_probe_device(struct docg3_cascade *cascade, int floor, struct device *dev) >> >> nomem4: >> kfree(docg3->bbt); >> + kfree(mtd->name); > > Please use devm_kasprintf() instead. Ok, will do it in v2. > >> nomem3: >> kfree(mtd); >> nomem2: > > > . >