From patchwork Mon Jan 4 04:11:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 356331 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp14658307jai; Sun, 3 Jan 2021 20:12:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJyoyFwtOeSeZB4EaDNtuGq1NNIjDWHI7uBCbC1x+GJO0qT6fkKUI5uprA78PNSO0OebAlyz X-Received: by 2002:a02:2ace:: with SMTP id w197mr60541923jaw.132.1609733538740; Sun, 03 Jan 2021 20:12:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609733538; cv=none; d=google.com; s=arc-20160816; b=gBO1NNLrZV3SSeHAsVYAHnIfzVrJX9AS0knhsK/xnDeRjBVy2XG3685iKGV5ERos8V wUaL/eOjXRA7j1FN700WpMHSsu7WScXDn0oJ+mC8d7ffiI4D42iqPHGt05CZVxd0xU1y y8oOua9ZZtEmh6TNFeDPz/xres84KMbAed3c9zcN0IbmR2b/23Od2jJ9TJcL1B8LIsyr Qat9KFBqjxcJ1kzn0N8cHcYSIZow3eoqLxZ2fAuMxJkZyTiiq5p6cqEjb9LvzMHH9w2N PCH5VIIKfUP1916QFtD6Cy77DLIDND3Fg3+s9qagL0yd8/1SFfwNi3yZjK1h2OnZxiw0 Zlvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mime-version:references:in-reply-to:message-id:date :subject:to:from:dkim-signature:dkim-signature; bh=v1SavrlOVRrF9Yl/3+44To7cZlMjrpdrp4UyO2SRF7M=; b=Vbzj3JDipTPnzQGrjO8kHa+rWxMOB1sTye66BPvJFClfxEKNZYn5RP27A77LCbSiis HCR4cnuCWdV9mk6ecOHWR30LEbaJxltWgJN9fXn1XZZRtMZ0CoaaNl1gdVPjbT0DLdd3 7ktZ9W6utJBYUy6VyJ4sxT9Oc9siNzcal5fcziMca4RNADjKC6eE4/LKhNofwIBOqBjc lnAK93lW9lBl995IiOjL2o5veFwfzrMzNYvcGFkVTdE+kNaE1YjicsrNk8PSGiqYJrrF fucd9mAS8hykMD6tlVCo6EY1PH/11l2T0Xl1HjKB0MgaqtYZuLFhPisOqW5PIlWPNt0A xcIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=merlin.20170209 header.b=pewlChqJ; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=kUog3bVT; 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 m10si39296541jaj.63.2021.01.03.20.12.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Jan 2021 20:12:18 -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=pewlChqJ; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=kUog3bVT; 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:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version: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=v1SavrlOVRrF9Yl/3+44To7cZlMjrpdrp4UyO2SRF7M=; b=pewlChqJxcuShIQOvyD70uv37 RupOKiHyx23XWn0CQxpY0PcqZ2fHc4IXeRt0rvOkEbahJBk7EQU6RV5I3SgzxOL2pEUUsNqqB3mNf Ltq4wFiVRXrx3ZLyMn3glj0o7HwgWHQ6tShORISXC//zcFwzV5fGxOH3tRU6raXqM33Ru4jlvCW2m iO9QCWoI0e2VAEIQZICck75682RdOaEEheX2hi1SDgeqhA9XvjKbdfcrtqAW59U84/kTEub1zhmzJ 0R8Z7jQa0BBjrvlJ6CEcErhCaNsk4Vs1w2iRNktSNNHuhSEdsjny6AQ9JJlRKHtRzFvc4lM0fpwDa WJctVpC5Q==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kwHE1-0002Qs-I2; Mon, 04 Jan 2021 04:12:09 +0000 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kwHDy-0002Pk-H3 for linux-mtd@lists.infradead.org; Mon, 04 Jan 2021 04:12:07 +0000 Received: by mail-pl1-x636.google.com with SMTP id q4so13818767plr.7 for ; Sun, 03 Jan 2021 20:12:05 -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 :mime-version:content-transfer-encoding; bh=wneBaSsM0xu86yHRW+fmULQ20sTukJwsm41Qy3J+Umg=; b=kUog3bVTIvYUWWUzjYQiRQyzxAlie5iBaP/m/YoCMjhOoCsT5F3U3JzXz4OfLihcw1 1Jfz8lCNkbUcL5zpmLYT36af6+u9c30idejRXIJnXxpoWV1itGu7GtGC+EeNuWsl9txK vsWQKMoxfakSo0jp85msmiCUaKTYvpvbXOcCcnjofk2XnHJxOk6ncEMs+sVEt3LhN4Ck SnN2gH1CzJhgK7MG4/RjaLccO4G+1/BNgtpUW7IeHVEYx1EIGFM8BeL+Hs2HSngLT2Ng si/ivAd11a85yLlElbr6ZR4yQSLZ8SrYFtGdOjBTClmTc4GfgJt7S2xED02PsfxuT/SR tkWw== 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:mime-version:content-transfer-encoding; bh=wneBaSsM0xu86yHRW+fmULQ20sTukJwsm41Qy3J+Umg=; b=IN+mc4cofl/rmkS6noaxxkuUeUu7Ruc5WAj5dbtqnz7VY32jY5Xs1MP2nBWc1xDgyJ tqNxWohaXsTJIShhCrm8RO8fbr0F1o/02INc4gYMHplkavGQlttpB9KHhD+neWDe4ryK klo7/IY3w3I5oHpyzm63y/9GxiZnu3FgOSOaokrE/gNa7m19uurh4Y/f5xNvCFjtZVYB jlUCv0QlVeB4WWmaF1NH7zwCZMO+c6aYswK5jXG+jhoIgqhePNMWvwudo7bYlPj1IFDI y66g6hB/mB4A4elWbPCagu3TOAmx16v3XzrGJv27n22L6mVKyzHVGrg0M6AQcIS0bls2 R2FQ== X-Gm-Message-State: AOAM531XHr2oTUXuRsd0V3HHtQ3lbKABoEoD859bzMmauRDnt1UcFLYz e8Wsp7D7v7DcfSd01Cl8pdSP X-Received: by 2002:a17:902:8d97:b029:dc:313:ee70 with SMTP id v23-20020a1709028d97b02900dc0313ee70mr70807129plo.82.1609733523386; Sun, 03 Jan 2021 20:12:03 -0800 (PST) Received: from localhost.localdomain ([103.77.37.160]) by smtp.gmail.com with ESMTPSA id x22sm54899930pfc.19.2021.01.03.20.11.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Jan 2021 20:12:02 -0800 (PST) From: Manivannan Sadhasivam To: miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, robh+dt@kernel.org Subject: [PATCH v4 4/4] mtd: parsers: afs: Fix freeing the part name memory in failure Date: Mon, 4 Jan 2021 09:41:37 +0530 Message-Id: <20210104041137.113075-5-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210104041137.113075-1-manivannan.sadhasivam@linaro.org> References: <20210104041137.113075-1-manivannan.sadhasivam@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210103_231206_613354_5B04EBDA X-CRM114-Status: GOOD ( 12.78 ) 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:636 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_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -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 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. Fixes: 1fca1f6abb38 ("mtd: afs: simplify partition parsing") Signed-off-by: Manivannan Sadhasivam Reviewed-by: Linus Walleij Cc: Linus Walleij --- drivers/mtd/parsers/afs.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) -- 2.25.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;