Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2087895imu; Thu, 24 Jan 2019 07:03:46 -0800 (PST) X-Google-Smtp-Source: ALg8bN7IATkbmsSd913YchzuLbMMHLWBPI71DHxraDJlwpQYhk6AC4CDwLh1lqtjBPPGduY7ddUc X-Received: by 2002:a65:610d:: with SMTP id z13mr6305136pgu.427.1548342226048; Thu, 24 Jan 2019 07:03:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548342226; cv=none; d=google.com; s=arc-20160816; b=D0zGXRqrlA0gT9IswnXeMjyqgbPT4Kkg8Je+dByyh4GAJgv9RYrBRYrjoLpq3fQQg7 6rsKNvaVLrMdu1x7tjpo5Rhn8DTwds6USBOVAakoKUOxA2QS874mm/IjwBdp7Gkphy65 UxmLheTwNxZVva5AIj5OZFl3p4U/5IdyqwBdLzqOcJY1M+FOoSzRTTlF6UDz6ptHN+jW yxN9c25vsuRqZY26lgkDvoEiWUuULuC6/OzaGGRjCT89kB6XZPrpC+IhYMjlfBgzo/2M ZEOx/f0F9SZbbnVxWAgBgIBt5r7eua4nF9+kxrP/Anr5yC9a3108bLDNeUv8PIEwwMmG jMWg== 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:subject:cc:to:from:date :dkim-signature; bh=N6c7fgCElMjnxMddyklo6iq+K/tAqSe54M8pv6BMAOc=; b=QXPWsjX48ik1ppKPgVUIZuLbTMGJ1HSsHM5KCKPtjtnYysjkwR0gxi1AWqy6UJz04y hKMFBzS6WQm1eFpiGiXJcnKryN1nRz2CG7IFy4XclCVimK5Ka+gSoRDzARZ8aUpfRKv5 iTcPchJtNUV4iOAQC4BImZct843jb10LCgrM5Yvl8wDzmeuAJ+UZrZdJPtx5/iEkKh0P jAimwku3a7db9aAVvrKcLPzjcf6BAN8lT+8FCXelKFzYxyXX5kG/gWGeCMbu23ntn8v0 U8NZEtiM556x+sKsIfg/RbaUkm4MU2GEYXTuOL86QcNxP3qWcKi4TMTPqJk8WyiAbMpG WkXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="w8EKL/an"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b10si21418154plz.233.2019.01.24.07.03.28; Thu, 24 Jan 2019 07:03:46 -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; dkim=pass header.i=@kernel.org header.s=default header.b="w8EKL/an"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728438AbfAXPA6 (ORCPT + 99 others); Thu, 24 Jan 2019 10:00:58 -0500 Received: from mail.kernel.org ([198.145.29.99]:34944 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728010AbfAXPA6 (ORCPT ); Thu, 24 Jan 2019 10:00:58 -0500 Received: from bbrezillon (91-160-177-164.subs.proxad.net [91.160.177.164]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 602D621872; Thu, 24 Jan 2019 15:00:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548342057; bh=7GO927NVdjxAU7TuJ/Pe/QGB7sFlePmjsQMNCa+HFtk=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=w8EKL/anIIpBhS1mJPYs2VrX49Fic9Yigok6eHlWFz7w9u7WhnUYDHvIakk93ChLc L+by6TU40Ky7thAyjVKvmfbid9FXDM5/I14kC8DRU31Nf5EDf318GvqCOUTycDbXaS gj9i1uOHlm9r5DFoFPFZnN3JzjhU9Ow1G2mWyUoc= Date: Thu, 24 Jan 2019 16:00:47 +0100 From: Boris Brezillon To: YueHaibing Cc: , , , , , , Subject: Re: [PATCH v3 -next] mtd: docg3: Fix a possible memory leak of mtd->name Message-ID: <20190124160047.6091b3e3@bbrezillon> In-Reply-To: <20190123092819.5020-1-yuehaibing@huawei.com> References: <20190123092819.5020-1-yuehaibing@huawei.com> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 23 Jan 2019 17:28:19 +0800 YueHaibing wrote: > In case DOC_CHIPID_G3, mtd->name is not freed in err handling path, > which is alloced by kasprintf(). Fix this by using devm_kasprintf(). > > Fixes: ae9d4934b2d7 ("mtd: docg3: add multiple floor support") > Signed-off-by: YueHaibing > --- > v3: use devm_kasprintf > --- > drivers/mtd/devices/docg3.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/mtd/devices/docg3.c b/drivers/mtd/devices/docg3.c > index 4c94fc0..59ca4f5 100644 > --- a/drivers/mtd/devices/docg3.c > +++ b/drivers/mtd/devices/docg3.c > @@ -1767,8 +1767,8 @@ static int __init doc_set_driver_info(int chip_id, struct mtd_info *mtd) > > switch (chip_id) { > case DOC_CHIPID_G3: > - mtd->name = kasprintf(GFP_KERNEL, "docg3.%d", > - docg3->device_id); > + mtd->name = devm_kasprintf(docg3->dev, GFP_KERNEL, "docg3.%d", > + docg3->device_id); You forgot to remove the kfree() in the ->remove() path. > if (!mtd->name) > return -ENOMEM; > docg3->max_block = 2047;