Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2971435ybl; Mon, 19 Aug 2019 10:05:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqybYicrUXhCo5/P0/RaK+TG/77U0vZAVAC7OYvjAznBt6EwzCN7ZiF60BObfxLcuRyPrkXT X-Received: by 2002:a62:8246:: with SMTP id w67mr25772324pfd.226.1566234340142; Mon, 19 Aug 2019 10:05:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566234340; cv=none; d=google.com; s=arc-20160816; b=tR9Qn55kSJmcvaj5s8bYynL1xS2q3DxOBZZgZCTh1ZdMxKgD0tiCsWZ69smcncIHdD EBjJOKDaRWqgHAeBv/seBCjfdBebyxMCn/dlWY7DMUO5sFvlZ8mY11arQRN0k+0JNfw5 zGrzSiYB+qG1Mx5bA2kyrJIZlh8/9gu+jqUqjjhCpav7jCyoxs3Xv8t92XqF37bJPuC/ HIJRLyuO/FCy/5IWQvpoe8tApuTeHX9mDE23iXlXAKyC8h9uUIfj5i8/vn2Stfxi4FNf aaorZ60c/sd7ePhB8C6Qy+Z4xq50iVPQEgZN1GMUDPNM9mqbDtYDnMHlvGnnkejNXq4c fjQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=3RV67E3mTNR4ClaoZBj7Q4TB/dFkdxGETOcIlk1/a/I=; b=dmROTomvTN5HFY7/iLf0XovaKfSCXGkhPGblWVSOTJdb4pUNe0JVhf3qzT8aSl0vdE eOs0u1UphUide4cfabsqpwe/wykqu9gZf/qZcZsA7cVbtXJJCfa2/1+XkXI+xsaV+fyk du8LTjbjH8gIhlde1UnqTErqur0bIOKXcC4zAgabSmPD+ChTgdor3KDoMDPtZvzVW0Nh gxzeYyapP1od16PNlvGeVG95C6CuBGPZ0e830ZOi+0EGvDtrHAKl5doRDReHRtCNxOkE e46QNJazFJWPTBqhMBGm2CfQFWhhANvwHSVHsil5G5MVjOmQO9kyWOFogX3la2iZujqG cWcQ== 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 i187si10837808pfe.21.2019.08.19.10.05.24; Mon, 19 Aug 2019 10:05:40 -0700 (PDT) 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 S1727653AbfHSREd (ORCPT + 99 others); Mon, 19 Aug 2019 13:04:33 -0400 Received: from ajax.cs.uga.edu ([128.192.4.6]:55394 "EHLO ajax.cs.uga.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726879AbfHSREd (ORCPT ); Mon, 19 Aug 2019 13:04:33 -0400 Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) (authenticated bits=0) by ajax.cs.uga.edu (8.14.4/8.14.4) with ESMTP id x7JH4UPt024745 (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Mon, 19 Aug 2019 13:04:31 -0400 Received: by mail-lf1-f53.google.com with SMTP id j17so1939286lfp.3 for ; Mon, 19 Aug 2019 10:04:31 -0700 (PDT) X-Gm-Message-State: APjAAAXqAhBRSIC3pIkbNEbY8HtO5Fx2jm8C23ISAzb+hpmycrC08i1c uLGDlu4vZXjVELZeGZvvs6mpJjcqiGAvmAJAjO8= X-Received: by 2002:ac2:442d:: with SMTP id w13mr13604474lfl.184.1566234269783; Mon, 19 Aug 2019 10:04:29 -0700 (PDT) MIME-Version: 1.0 References: <1566149993-2748-1-git-send-email-wenwen@cs.uga.edu> In-Reply-To: From: Wenwen Wang Date: Mon, 19 Aug 2019 13:03:53 -0400 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] mtd: spi-nor: fix a memory leak bug To: Tudor Ambarus Cc: Marek Vasut , David Woodhouse , Brian Norris , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , "open list:NAND FLASH SUBSYSTEM" , open list , Wenwen Wang Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Aug 19, 2019 at 2:03 AM wrote: > > > > On 08/18/2019 08:39 PM, Wenwen Wang wrote: > > In spi_nor_parse_4bait(), 'dwords' is allocated through kmalloc(). However, > > it is not deallocated in the following execution if spi_nor_read_sfdp() > > fails, leading to a memory leak. To fix this issue, free 'dwords' before > > returning the error. > > Looks good. Would you add a Fixes tag? Sure, I will add the Fixes tag and resubmit the patch. Thanks! Wenwen > > > > Signed-off-by: Wenwen Wang > > --- > > drivers/mtd/spi-nor/spi-nor.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c > > index 03cc788..a41a466 100644 > > --- a/drivers/mtd/spi-nor/spi-nor.c > > +++ b/drivers/mtd/spi-nor/spi-nor.c > > @@ -3453,7 +3453,7 @@ static int spi_nor_parse_4bait(struct spi_nor *nor, > > addr = SFDP_PARAM_HEADER_PTP(param_header); > > ret = spi_nor_read_sfdp(nor, addr, len, dwords); > > if (ret) > > - return ret; > > + goto out; > > > > /* Fix endianness of the 4BAIT DWORDs. */ > > for (i = 0; i < SFDP_4BAIT_DWORD_MAX; i++) > >