From patchwork Tue Nov 17 17:48:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 325524 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:5ce:0:0:0:0 with SMTP id l14csp4369602ils; Tue, 17 Nov 2020 09:49:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJzKMVavesJNumxpH9vREv9SzDLhw90W6mEq1ctsWTjhb6Gz9VgcHWysbU7Cc53aRuZylJ6s X-Received: by 2002:a1c:5f84:: with SMTP id t126mr247930wmb.172.1605635375239; Tue, 17 Nov 2020 09:49:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605635375; cv=none; d=google.com; s=arc-20160816; b=tv7a5vcgB9ZBA9N8FwMQ5tAA21ICkMPwSUG15WG737AG3UPY+/tGjjykjP+YgSZkHj kwkn5UMH2dafupZ/GZ03rOZkEQ4NJqiwicb58ORYaQLxO9cwhsdSoROZyNa8pEI+dyQM M3+OQFU+tCmJ85Y10FmuCRfdgmHS3MEFXVNhhcD6D3GX0OEJmq/yl6VsAcv7XAI72sU6 Z+UfWrt1E/4qZCmYXyhC54E1GII6/3cUmebupbcpmFw54bCKT9BsQKWUQq5Wy40+l5El hEZyDxQ4jUW7o3eGLK8TFJ84r1/CRwBj5ms3xhF2QyKtvU2ss+MpGslAbwRKgZUpqrHy PxdA== 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=O1VDfGgtEilHiPEXsZ9/7Hj9bvorPA+ooErhipMZexA=; b=VTZ3Qsc4ejLY5kl2QeKz2L+w2hzjsg+s9A5Kmc06q8+eiwoGScfpxFVgSFxuepskj4 deHsvk47WsZGcob4qFew95M6rczP5aOjX/YjH6AmbyaC++b50E1RUrHIsFXSDDVeXPBB KUfDhbHJ2IsMMVnJhr8g8A6ZdwHu1KVMbmiERBLaI4GJSkj0rb3AMFCD3oTA7nrY+oju VAlIJ/1+6dDOwzIgpCCifYd3DB5OkWO7bzBFV4mw8bXMkwfD6bHyqxCTOMjFJsxTu3Ke AW4T6I73S0GqfEcoqORlz2D1UOGJgKoWVQg5kvVz5+PYjLzlmRvc+bmvlH8mBkAjmUN3 r9gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=merlin.20170209 header.b="McuaBG/N"; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=GrQmJSal; 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 h16si20182828wrm.221.2020.11.17.09.49.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Nov 2020 09:49:35 -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="McuaBG/N"; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=GrQmJSal; 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=O1VDfGgtEilHiPEXsZ9/7Hj9bvorPA+ooErhipMZexA=; b=McuaBG/NN9vBhgGye7ROQwKhS7 0bZCVdaeIeqR7jj4vfYBCbOas8zzE7hhvboIVThw/Q44tTcJhfe6LGiwcrcDk9UawDTv1XYCa1+Xe 3yTfFqLxbPErcBdWiLzs3lBw0oa8FGqgtZhhapl4ByzupWN1Ls1WozQrcxIwsIgQLlDJJ2+voSuZt 8RVT/iVWElXv0F9LFpJw+RN0x8BV6Ru6j5QyIXaAHQKQW+5KRKn5J3wVHA+LthYPzSXDnkaY7CYKl lpfyTAh3OMzkUjEaDRm9X7rzXqBqiv7Fl9NRMRlqIbGcU/rmw7CfUt0Kxh7J3OmWIMwKdGRAe/q+y 3Y6AdxKQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kf56b-0007FR-H1; Tue, 17 Nov 2020 17:49:25 +0000 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kf56P-0007AR-G6 for linux-mtd@lists.infradead.org; Tue, 17 Nov 2020 17:49:14 +0000 Received: by mail-pg1-x541.google.com with SMTP id i13so16521943pgm.9 for ; Tue, 17 Nov 2020 09:49:12 -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=EAf9d4gGWEUWE1b+AMgq6WQ0FcZNv1uCLoEh96U6HDQ=; b=GrQmJSaliPTve3DL04A9GAepxzDBPQmaJDXflI0uIc24Ceqru5Te8SBteMXYibBiWV YXtyBkZcp4alV78euGq8ZrdXrY/s1xTOqwOzjdB/goMB33KUlG5kJWFx/V0Hqrk3JZEp zw7ndp6YX9rmihiKPQuebdAS2Wg2Jl1+n+zNJJHekxbJkjfpKusp/zA2T2t21GcxUBBV sZr+xgHWq6+/6X33ZHMmafEYZVgWboH6fcuIKZcdfC7uKZ/Gc2XP02Uwep7dMXIQHRUe AZFf9CI2yybVt/jWzI+IT2jw9m6POx/FLGVpicrbqCfBClD5HoQVjXuKaz0ESjdzURvc ZuuQ== 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=EAf9d4gGWEUWE1b+AMgq6WQ0FcZNv1uCLoEh96U6HDQ=; b=iMpzKneyHvPzq6ZdLrhlrHIIsC+RR2L8l9eJLwCmg1iY4u/dF514VfgrwkSJJEG2HO QhECu54nZ5PPfBhUsWFIXO3NiewhzOEE0DF/u45MFj2ZMo+lGuJKir6MHLliNKF6l70a pyDArRCuxml0tywUPQMk3fwBMXx7RN6fzYMfT5RUSBYdoOOhmubunNKxbgu/DuRhw7U1 B7JDOqHEbhF+/sr0X1pghCAuAr3E0hJ/3KcvKfqkx8NdS1GQejS8fQYIwFcfE1O8taHv nkMIM0qjvYtodDk26h0btRv/eY24/mFV4Vx0V9YxS/dO03wt9RIyfeevhhqufJ2gAo1l 7rpQ== X-Gm-Message-State: AOAM532zjyLduDFP7zBUItBK6QT8NxS1ElacmGaGhf9EiD2QDDGvSVtv eS7WmpjgbUsuvZqblETy67kspmPXh+7j X-Received: by 2002:a65:55ce:: with SMTP id k14mr4432790pgs.65.1605635350991; Tue, 17 Nov 2020 09:49:10 -0800 (PST) Received: from localhost.localdomain ([103.59.133.81]) by smtp.googlemail.com with ESMTPSA id 192sm22222810pfz.200.2020.11.17.09.49.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Nov 2020 09:49:10 -0800 (PST) From: Manivannan Sadhasivam To: miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, robh+dt@kernel.org Subject: [PATCH v2 4/4] mtd: parsers: afs: Fix freeing the part name memory in failure Date: Tue, 17 Nov 2020 23:18:45 +0530 Message-Id: <20201117174845.28684-5-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201117174845.28684-1-manivannan.sadhasivam@linaro.org> References: <20201117174845.28684-1-manivannan.sadhasivam@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201117_124913_583261_3D7FA8B0 X-CRM114-Status: GOOD ( 14.35 ) 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:541 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 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 -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 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") 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;