From patchwork Thu Nov 19 07:13:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 328379 Delivered-To: patch@linaro.org Received: by 2002:a17:907:2110:0:0:0:0 with SMTP id qn16csp116948ejb; Wed, 18 Nov 2020 23:14:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJyD1hunwTSTs8huUUE2EcmFaqG9XWAEPQEWKlNyydT9HKcKeYWSDUlzWaRqaJoq0vgYRNtQ X-Received: by 2002:a5d:6506:: with SMTP id x6mr9141330wru.175.1605770043312; Wed, 18 Nov 2020 23:14:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605770043; cv=none; d=google.com; s=arc-20160816; b=NGvAOHqlIkDYgmA0k0FNh4PS1GKDRzry5Xmcj9rtRpLIdMzLVyxBtUfofC7ESXJMJx JbAVHAEEPS2UPQoEHrdrfpu+h66wTQMCXUzVz519pxNjhVFTRJ8VMDMNGzgMXC7KmgG+ 0sPvex4+EjTv7o2tY2MqYB/rjOczYqU+/TGgdUlnCCTOpTBub8eWamGxYYDVhI/QMVh+ rn3B+3HlCzi6HMTBMemQkdbeATZYbhytwPK4PuD4307WyMtHEMJ3v9/tZUXdaRz+RXOc cxiIYmCt9C+ngTzX8JWY17Kg8M/NWLHlhYa7+mVZi/R5VpWuwEbuS8uBmvjWO0Dx+k7/ C5Xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:references:in-reply-to:message-id:date:subject :to:from:dkim-signature:dkim-signature; bh=EJXX6BpLckPv7T3dPcAMzIc4MlFYYxN8MtLccvSyM+0=; b=PH7b6FlA/YDOhLzzRQRrdOe5TgSjF4tnTfeWe6HmnOvJeuFinvHTIkhMAkp+SkfM+b s9tx7TnzO0HwXhR0dKiXT9KTQAY0hXc+DXUcJwctvThiJTjE2EhRptHJZxR3d+GQyiCo L+BbItI+tQYd/1wpxdOCDaKoSVka9FqkbCZ55ldfabvD0Lo5/C9nL55yGt9s/dxLou4K plNVAU+aOa0/SA7jAY4FStp2wyVVyb21y9nmSA0t7Rh9wEPck5yAZkqGLM1ZPpfd80HJ bNq/7XTlrujtGhdaXVAYrJTsNlqsip9P3r3TTOCM9Its6uAE7G2wFvf9/xVqdPanFeeH lJ/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=merlin.20170209 header.b=DBh+m0Aw; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=qgWlpJRt; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2001:8b0:10b:1231::1 as permitted sender) smtp.mailfrom="linux-mtd-bounces+patch=linaro.org@lists.infradead.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from merlin.infradead.org (merlin.infradead.org. [2001:8b0:10b:1231::1]) by mx.google.com with ESMTPS id f7si582323wrx.332.2020.11.18.23.14.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Nov 2020 23:14:03 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2001:8b0:10b:1231::1 as permitted sender) client-ip=2001:8b0:10b:1231::1; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=merlin.20170209 header.b=DBh+m0Aw; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=qgWlpJRt; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2001:8b0:10b:1231::1 as permitted sender) smtp.mailfrom="linux-mtd-bounces+patch=linaro.org@lists.infradead.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:To: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=EJXX6BpLckPv7T3dPcAMzIc4MlFYYxN8MtLccvSyM+0=; b=DBh+m0Awalo0kxm72eWUXnGtE6 XZQTQOY5FOpd6vZNxor9YRpgQ1pzmj281cRdIbiUesbEN8x0m51KBtOkS2BDSaPZewXp5qK8a+klA OpU/aUqd2NSGA5loHL5cZ6qtry2O9q8TuPTlmv/sJIomvPAOH62o80zN9wcvd0qPx+vQVRaG6TgGm GrCoJwUEbB5c6WJTmt/I3Y0jNixlnSNcp+LoD8KoR0rw1Mr1SqN60JO7TmSYJoGiFPdv9ttLtZw4I wNi4E1nxhGsm6dA6dKDsHTQnlKE+3W+2qHTirok/5/ynPWplRQm5fmdJnpgiNyMn/zO9GZOSBZ+tr lbhVkVkw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kfe8f-0005qE-S1; Thu, 19 Nov 2020 07:13:53 +0000 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kfe8Y-0005o9-2J for linux-mtd@lists.infradead.org; Thu, 19 Nov 2020 07:13:46 +0000 Received: by mail-pg1-x543.google.com with SMTP id 34so3390151pgp.10 for ; Wed, 18 Nov 2020 23:13:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=aapWpWlyJG4BRZvNWpxnSiKXabtbA1WEoNDKMnXBWMg=; b=qgWlpJRtvQvY++Dn2/UpaiG/tLsPm+RlkTuBkKurklKGiW6comp6026pG/rrJE5H9s Jvk8jJuWq4Rmp7o3owcGR826LFXlnudvx23sSDp7tOXziagznab4Xu/yqFRqW91nuLpg oddCSmZB+jJQZcvwEZy+kadZpuFNxNRVyHJOXrjEsjC3XSrDx5kYfxTW9YHmyjS9YH5o sgRWaev0MOcbaeZrDF5y0KNkiRpi/kko7dycJ4xxtMSLRG1WgLOpHPXTmUa8T0Lwj487 Z2bzhg0NQVo1PhiaH/PrUtoyRFbTUM47fiwe92cnxelpWzoWVcdqwTR5ci+L8dRHwkQR Ixgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=aapWpWlyJG4BRZvNWpxnSiKXabtbA1WEoNDKMnXBWMg=; b=Pk7mMeK2aMIjjRjjScn6x07gjCIdwa4gqfNpVDn75+aPO2tFnpAvcHNJ4cEfYfDzxh zDxxcSzJk7yw9FHvceei9IbOiYG0Uu8QcFYVk6a0q0nXKakf61vUTEV7s+f6Tlk4O9B5 8pHMN+T6t1N17S11Eb4iONvqLDrPc3qf+ljaoBhmoeFv5a0Iu8o54gM5Zep7gU27wL1E w62J7jvZXw438wEej1U8IPAz77DbX/Ot2Xqs0YRxVoxxkEzKgEKJNiC4/6skMYNyosYU BGDTOI4geev9IX9iJrKi3DgAA6x4o4EfGwGte+Cnz6DsANfbU/QBREeJZQoO5rgdjPrS wIag== X-Gm-Message-State: AOAM533nmtCaO93AY5kyHvDydF0ffp3mTKc+SP4xMjnFoucPfzRFJQJ4 IHhr+x8xfFxLrpYMa/G0khru X-Received: by 2002:a62:8608:0:b029:18b:a8e:ee9 with SMTP id x8-20020a6286080000b029018b0a8e0ee9mr8008802pfd.65.1605770021344; Wed, 18 Nov 2020 23:13:41 -0800 (PST) Received: from localhost.localdomain ([103.59.133.81]) by smtp.googlemail.com with ESMTPSA id 12sm5491577pjt.25.2020.11.18.23.13.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Nov 2020 23:13:40 -0800 (PST) From: Manivannan Sadhasivam To: miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, robh+dt@kernel.org Subject: [PATCH v3 4/4] mtd: parsers: afs: Fix freeing the part name memory in failure Date: Thu, 19 Nov 2020 12:43:08 +0530 Message-Id: <20201119071308.9292-5-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201119071308.9292-1-manivannan.sadhasivam@linaro.org> References: <20201119071308.9292-1-manivannan.sadhasivam@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201119_021346_180596_0FC15EFB X-CRM114-Status: GOOD ( 14.30 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:543 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, linux-arm-msm@vger.kernel.org, Linus Walleij , linux-kernel@vger.kernel.org, bjorn.andersson@linaro.org, linux-mtd@lists.infradead.org, Manivannan Sadhasivam MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+patch=linaro.org@lists.infradead.org In the case of failure while parsing the partitions, the iterator should be pre decremented by one before starting to free the memory allocated by kstrdup(). Because in the failure case, kstrdup() will not succeed and thus no memory will be allocated for the current iteration. Cc: Linus Walleij Fixes: 1fca1f6abb38 ("mtd: afs: simplify partition parsing") Reviewed-by: Linus Walleij Signed-off-by: Manivannan Sadhasivam --- drivers/mtd/parsers/afs.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) -- 2.17.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ diff --git a/drivers/mtd/parsers/afs.c b/drivers/mtd/parsers/afs.c index 980e332bdac4..26116694c821 100644 --- a/drivers/mtd/parsers/afs.c +++ b/drivers/mtd/parsers/afs.c @@ -370,10 +370,8 @@ static int parse_afs_partitions(struct mtd_info *mtd, return i; out_free_parts: - while (i >= 0) { + while (--i >= 0) kfree(parts[i].name); - i--; - } kfree(parts); *pparts = NULL; return ret;