Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp8623643imu; Thu, 15 Nov 2018 14:46:54 -0800 (PST) X-Google-Smtp-Source: AJdET5fE5dz/1JAnI9lc5OhQ4WPAUQOpx4dGjMlZXhdEZlZHsgXv9vAMAF7rX5XCs21ds/tBzRlq X-Received: by 2002:a63:4566:: with SMTP id u38mr7576294pgk.4.1542322014847; Thu, 15 Nov 2018 14:46:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542322014; cv=none; d=google.com; s=arc-20160816; b=SBRbBvUCELN2AIeN4KvNL6EiJokoyG2i4FdgPlVRiLaOnBrHXuXNgTZkrxtaZKCZ+E Cvp20VMxW0pLOjgUBPVZVe95I4jwlTawuz+57a+qPgLBqeCPIvJo49ElYySyIleEulIG QHg6jE00Ot72a8Iz/IvyIDCbgH0Z69w7ar0t9t8ETxhcpzdRrLVGb4371tAFFkakn9cO jvHUDEO1D5Uu1w6VXs6qdFkZlPpVeyQKLR2G2Fvnrz9W+TN795L2UBD3fFFadOx1p3Nt plS4H6s9BeWWyLvpZFtGMGTmNw5Pb6SiVZ8nEGTU453Jz9tRY04HSpkIb4lDkSR2BGTf z8YA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:openpgp:from:references:cc:to:subject; bh=YnwX6wljXYX0AePSR9MQ5s9wDG/+QoWI9m3IVVFPmVw=; b=IAGmqgQBp5IMBXhtBG2JjZGIATE6xiEEaGUXOE8Gwna+C10aiIZ61EZtRdOPWBlXP1 V/u9npCj2fxEHnEQie2XHv1wL5STZAFgiK1jLYsBYEBML9ouAbKIUw79HpCV/Le4VqYt opMWIw0WA+mrDbsIjHge54JLGbS0Wqa0kt5BFZ3uZ7lSz2KoWYeTXt9aJSHFkRCq72wm Ji25iywmAyiEFvgDvL1sVR+IR2fNozX30IzSNI70o1qCSgXpE2Up6SR4lHRG7hZXkBQQ 9+bGznPPlYE3mrb/0FEuE1lIh5h6AbEfOugrqIVEid9U7DenoP6rtI/qWjXPGgVy8nXy x+WQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 59-v6si5018277plp.291.2018.11.15.14.46.39; Thu, 15 Nov 2018 14:46:54 -0800 (PST) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388865AbeKPIzm (ORCPT + 99 others); Fri, 16 Nov 2018 03:55:42 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:49510 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725916AbeKPIzm (ORCPT ); Fri, 16 Nov 2018 03:55:42 -0500 Received: from cpc129250-craw9-2-0-cust139.know.cable.virginm.net ([82.43.126.140] helo=[192.168.0.11]) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1gNQOE-0007VR-7O; Thu, 15 Nov 2018 22:45:34 +0000 Subject: Re: [PATCH] ubifs: fix memory leak on error condition To: Richard Weinberger , Garry McNulty Cc: linux-mtd@lists.infradead.org, dedekind1@gmail.com, adrian.hunter@intel.com, s.hauer@pengutronix.de, linux-kernel@vger.kernel.org References: <20181115203850.5774-1-garrmcnu@gmail.com> <2181429.CC2M8HkSot@blindfold> From: Colin Ian King Openpgp: preference=signencrypt Autocrypt: addr=colin.king@canonical.com; prefer-encrypt=mutual; keydata= xsFNBE6TJCgBEACo6nMNvy06zNKj5tiwDsXXS+LhT+LwtEsy9EnraKYXAf2xwazcICSjX06e fanlyhB0figzQO0n/tP7BcfMVNG7n1+DC71mSyRK1ZERcG1523ajvdZOxbBCTvTitYOy3bjs +LXKqeVMhK3mRvdTjjmVpWnWqJ1LL+Hn12ysDVVfkbtuIm2NoaSEC8Ae8LSSyCMecd22d9Pn LR4UeFgrWEkQsqROq6ZDJT9pBLGe1ZS0pVGhkRyBP9GP65oPev39SmfAx9R92SYJygCy0pPv BMWKvEZS/7bpetPNx6l2xu9UvwoeEbpzUvH26PHO3DDAv0ynJugPCoxlGPVf3zcfGQxy3oty dNTWkP6Wh3Q85m+AlifgKZudjZLrO6c+fAw/jFu1UMjNuyhgShtFU7NvEzL3RqzFf9O1qM2m uj83IeFQ1FZ65QAiCdTa3npz1vHc7N4uEQBUxyXgXfCI+A5yDnjHwzU0Y3RYS52TA3nfa08y LGPLTf5wyAREkFYou20vh5vRvPASoXx6auVf1MuxokDShVhxLpryBnlKCobs4voxN54BUO7m zuERXN8kadsxGFzItAyfKYzEiJrpUB1yhm78AecDyiPlMjl99xXk0zs9lcKriaByVUv/NsyJ FQj/kmdxox3XHi9K29kopFszm1tFiDwCFr/xumbZcMY17Yi2bQARAQABzSJDb2xpbiBLaW5n IDxjb2xpbi5raW5nQHVidW50dS5jb20+wsF3BBMBCAAhBQJPCrjvAhsDBQsJCAcDBRUKCQgL BRYCAwEAAh4BAheAAAoJEGjCh9/GqAImjVsP/iA8hDQy7LlMYepND9tKJD2haNLmsBC+yuxX BybYprtSjwvMbx6CtmtiJ4nGfdBzbZv3xOJPr/n6wxrdfGHEFn0W8Au97Xvk087P7alCwBXz y1Hk1aTlhLOGunOLv6SWRYRUAHvWEoVlxPSo2UNJ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SarV7/IqjLb0uMTz6Ng7 SceqjsgxO4J35pPOCG8gy85Tmd5NKe46K1xGsNG2zzfXQ6cNkofUyQFGVbLCtdfQyWV7+dgU nOnPhrTKpFfJ5lnWpLpze0LfyW03CpWx9x4yMlwcvIFw2hLaOQARAQABwsFfBBgBCAAJBQJO kyQoAhsMAAoJEGjCh9/GqAImeJYP/jdppMeb7AZnLGVXd8rN7CLBtfMOkXCWaOUhjMRAY7dV IMiF1iPZc6SgiiMSsdG7JJhMjMuLTxA0kX2Z6P0+6dZlO4bDOKMIv4nNGhgSj9NuSKJPRiyi XKKD/wNnPXVFdBZsoHnEXGyAFGnidu4KLUJIiSm4tHJdoMk0ZaJSmwt0dtytuC1IWH8eIaVo /Ah6FxCaznRzvGNFx+9Ofcc7+aMZ15dkg9XagOuiDZ1/r6VuEw9ovnkDT4H5BAsysxo/qykX 4XQ2RQSY/P3td9WNLeXLvt1aJNRcwcIEKgZ5AO3YQbEJt1dEfCU7TAKiRpsjnC/iQiQHGt2I vNci8oZmM3EQEi7yZqD07A6dpGTnRq9OQ7fGhj0SS99yZvooH3fBIHA2LRuvhfDAgTrpbU0w LvkAIo0T2b9SoRCV8FEpHvR2b86NbTU5WN4eqZQbAbnxC7tJp6kLx2Zn2uQMvfXRfnS9R1ja etvpk3h7F+r/RAAh+EvgsPUNaiRJRRLvf9bxTQZhmNrw79eIFNsRIktniLyomJf2+WPOUECz h1lfLqe9yiuUKv+m5uAalXdayhiPbp/JHs1EDRgSq3tiirOsKrh/KMpwz/22qGMRBjFwYBhf 6ozgujmPlO5DVFtzfwOydzNlXTky7t4VU8yTGXZTJprIO+Gs72Q1e+XVIoKl3MIx Message-ID: <560ceae1-e9f1-26ca-e1b2-3568e38a4e28@canonical.com> Date: Thu, 15 Nov 2018 22:45:33 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <2181429.CC2M8HkSot@blindfold> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 15/11/2018 21:42, Richard Weinberger wrote: > Am Donnerstag, 15. November 2018, 21:38:50 CET schrieb Garry McNulty: >> If the call to ubifs_read_nnode() fails in ubifs_lpt_calc_hash() an >> error is returned without freeing the memory allocated to 'buf'. >> Jump to 'out' label to free allocated memory and return the error code. >> >> Detected by CoverityScan, CID 1441025 ("Resource leak") >> >> Signed-off-by: Garry McNulty >> --- >> fs/ubifs/lpt.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/fs/ubifs/lpt.c b/fs/ubifs/lpt.c >> index d1d5e96350dd..c162459a1e02 100644 >> --- a/fs/ubifs/lpt.c >> +++ b/fs/ubifs/lpt.c >> @@ -1688,7 +1688,7 @@ int ubifs_lpt_calc_hash(struct ubifs_info *c, u8 *hash) >> if (!c->nroot) { >> err = ubifs_read_nnode(c, NULL, 0); >> if (err) >> - return err; >> + goto out; >> } >> >> cnode = (struct ubifs_cnode *)c->nroot; > > Please see: > http://lists.infradead.org/pipermail/linux-mtd/2018-October/085081.html > > If Colin won't send a v2, please do you so, then I'll take your v2. Please take Garry's V2, sorry, I somehow overlooked doing a V2. > > Thanks, > //richard > >