Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5034718pxj; Wed, 26 May 2021 00:54:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxOFUQhezu6yKbNRLrD7LGRAfxsMiJYc80NxKUb8EgAoNwadNTCjFvdyU4SgcVCLijlkNEN X-Received: by 2002:a92:d689:: with SMTP id p9mr22490497iln.242.1622015668675; Wed, 26 May 2021 00:54:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622015668; cv=none; d=google.com; s=arc-20160816; b=YW+9pWlyV7dbwiHOjvLYy1zdWmn8ytHDXvjLacYl9tUpdr+7BpRMKsKNv0IUJ3BgZR LQL0QJ1yWoYsb7Js0/mtDXWP1U0aa7GQFhu2we4UXfzlu3KVVm96W5q4rYwr7phDPhKm f2UiJFuA5vwsrt4s6FuGQUcOMICTtlp0lMUHrsaud5R2b0TEBp75Uhh6jTN9IwuTUxuS RVLGbXYT8WFeJl1IgUvRarEIuZSsmIdW6xSw97UpFhwOxir1f14gMo7/VaWJG/x+9m0O kmYer/uNFEZA4MOBLvqOMHZv0ECXBNv1Khrg4nfC8NdUlJ/92BKQ3T3HLOGrxAfoZGZ1 VKLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=3JTT1UF8fjZtOwMpEhq/hD0q4JpRMkd1mansC0wGmX4=; b=o6ywFdvekpAQO5rnHIzRz2vSOsp4s5TwDLHgG/n4wu7LF7ctaZyY40cGt99U90Q5c5 SfoK76zKBNaQg6eycaEBYfhZbDlUbQ8KD/bK39+bTnqH5wz1AKDlHNax2/En/cxfWKIZ UWUYay9clC5ph9400KYdhk3qbG1V82NXujGqah2+iZxipFbEtky7RZil7u/HBi+kEB67 Qt3HNNlJbTw8kP9CmMZm8Edra4BF4W/gvPfpjEBDEjW4MeoBxQqFfqfI1nQrkpsTsvfI EiKTkk65bzef6Wbbr03yfzM0kR6bMhDBk/8eCi7TL0jTE1mtoYlju0V6j3qqQFAD6+hp hMFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WEMmgUWH; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h17si7660785jas.28.2021.05.26.00.54.15; Wed, 26 May 2021 00:54:28 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WEMmgUWH; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232452AbhEZGE2 (ORCPT + 99 others); Wed, 26 May 2021 02:04:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:51318 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231657AbhEZGE0 (ORCPT ); Wed, 26 May 2021 02:04:26 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 46290613CC; Wed, 26 May 2021 06:02:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1622008975; bh=Px4RLhRm+fl/7hIdMPYO+uGgtTr0sXe6bUIxzTzzwQw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=WEMmgUWHwEVFXB1PkX1xij4Xz97EIBpu0xIngzEIpiwZHJnUjowxHp89dkSv2XWjb MmkiK+rlLYmsOAxSP3apdMVwmzIgg96RbtgglKWkyJlwWUdQwa/3BwSr6OHGcpUCaO NzvWwdpz/qq6EnGNgjAaBIRAijjRmb2Fv8Cb8z9cpjqhRusb+5K691cC6+G0b+8FHn Y1iPRtsE0wXkW/W4O0gNvcsdsDHQV3wY/uIWi5BUd0Hnx++c3vEj9Tv0WJ4anolKry Eiq4AtxxfbAheIHtW9j0yatm+C6ZovTgbvm2Ydq5w2620YSY1lFXecaom6+x0L2vfj sFJQOiVWckFvw== Date: Wed, 26 May 2021 11:32:46 +0530 From: Manivannan Sadhasivam To: Ansuel Smith Cc: Andy Gross , Bjorn Andersson , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , linux-arm-msm@vger.kernel.org, linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] mtd: parsers: qcom: Fix leaking of partition name Message-ID: <20210526060246.GA10723@work> References: <20210525230931.30013-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210525230931.30013-1-ansuelsmth@gmail.com> User-Agent: Mutt/1.9.4 (2018-02-28) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 26, 2021 at 01:09:31AM +0200, Ansuel Smith wrote: > Add cleanup function as the name variable for the partition name was > allocaed but never freed after the use as the add mtd function > duplicate the name and free the pparts struct as the partition name is > assumed to be static. > The leak was found using kmemleak. > > Fixes: 803eb124e1a6 ("mtd: parsers: Add Qcom SMEM parser") > Signed-off-by: Ansuel Smith Reviewed-by: Manivannan Sadhasivam Thanks, Mani > --- > drivers/mtd/parsers/qcomsmempart.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/drivers/mtd/parsers/qcomsmempart.c b/drivers/mtd/parsers/qcomsmempart.c > index d9083308f6ba..06a818cd2433 100644 > --- a/drivers/mtd/parsers/qcomsmempart.c > +++ b/drivers/mtd/parsers/qcomsmempart.c > @@ -159,6 +159,15 @@ static int parse_qcomsmem_part(struct mtd_info *mtd, > return ret; > } > > +static void parse_qcomsmem_cleanup(const struct mtd_partition *pparts, > + int nr_parts) > +{ > + int i; > + > + for (i = 0; i < nr_parts; i++) > + kfree(pparts[i].name); > +} > + > static const struct of_device_id qcomsmem_of_match_table[] = { > { .compatible = "qcom,smem-part" }, > {}, > @@ -167,6 +176,7 @@ MODULE_DEVICE_TABLE(of, qcomsmem_of_match_table); > > static struct mtd_part_parser mtd_parser_qcomsmem = { > .parse_fn = parse_qcomsmem_part, > + .cleanup = parse_qcomsmem_cleanup, > .name = "qcomsmem", > .of_match_table = qcomsmem_of_match_table, > }; > -- > 2.31.1 >