From patchwork Thu Nov 15 20:38:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Garry McNulty X-Patchwork-Id: 998537 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Y/7ch5ka"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="UDdmsuOJ"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42wtWj0GB6z9s5c for ; Fri, 16 Nov 2018 07:39:28 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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:In-Reply-To: References:List-Owner; bh=5Hgya7eYzEfTnTQBzanKa4L+tX4hZOegYTyhe0j72+0=; b=Y/7 ch5kaNayShlaNqhdQB6A2hJBbC9QPpBmDMFB2l4k6obkIJiUKWqtRi+J0NxUQgLCrg+7+1Pp8vC/7 M6eyiSNVtdFTkx8wm8L0tdO39ftjcp53AjeBxUME7bz57ay4xgeh1tSTqXxX02DwLi9CknrGu6Lk7 7wFovF+rUwEUuV7ns+/5yaXaZEVQNNGQQhFXRErspoX0DerQJTo7rcu41p4urN+w18YWJBFHv2GCg 8sJJMqhLTsjno2K64Fa0jaqJYxaKg8SQzNbifnHuUghQkjRKzNi4ri5QCkr+EN/sF8QA1gMoyEEFU wKfxk8cm6sFHGSWx2NuZVr6Qwogsikw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gNOPx-0003Ya-T2; Thu, 15 Nov 2018 20:39:13 +0000 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gNOPv-0003Xi-Du for linux-mtd@lists.infradead.org; Thu, 15 Nov 2018 20:39:12 +0000 Received: by mail-wr1-x443.google.com with SMTP id v18-v6so22611390wrt.8 for ; Thu, 15 Nov 2018 12:38:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=uuIb9FIXKub0D/vDvuhH1Mn5qLYT4uNO74xEcum8ksM=; b=UDdmsuOJOsHJ/4PWRF8P4gH0hbVvSQ3awgUGO+aoEGllDzb7txjcu4cPfThwrrk3rl Ixw6yQ0aqOyTZylbPzP0s/csA9IcKQ8MYdO+dC09ZmYAsgIvE15f5n5jSasqxQrVCLNF wra6zloUNiLKMTDx3rx/nJGzwdMiav/XEnwlQ/wIZDOugVlPkz1nXaUZpA/VYIq2WJ2f xhvoRiyOHtfYG3Fw4/T2H7uWImPbURZF6aXikoYJYH6oyo/2+GPLgnrc7GLPuQBe7teX 3dHJ9fikKhodblg8YHHsF7wJz887x5CCu7oe4uonKwZcFW+OMJ6t8fUZzkTc6gTQKQKr iwiQ== 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; bh=uuIb9FIXKub0D/vDvuhH1Mn5qLYT4uNO74xEcum8ksM=; b=kjC/llZ7OOl7COhCikrc0H4AWppf4DsUQsVq65sG0ZlkY7+YmScsiMhuqncbnIhup5 VfV1cxWtRoc5uOer6ZSGeI8oikBwtjb5Bs3iXwPdBKS5mN2Wet/vFKgwLxxzIq9yPRtP 07We8lH1/LSdsciXwkKScAb2hxhipdpJhNtAWz9RXj0XIv5QTwY91w0hPkF3A42/qppy p0wD2gULQSa3YhUdL4g2b/LBelQiRNbTcyfSrLa5pOrpkJsYF4UtGApJDU48mfwM8kdv C/3XwBN9nRYC2uTWI3bMAJntQdefNdoQGquQmaeqzzuJyzpHC4qIDPP+R9vUo4zaJpl0 XRKQ== X-Gm-Message-State: AGRZ1gIRvJLjLngPlJTJ9qdLLB9hAK43X+hZQNRQ1UQf9DiAIkbPgdu8 XJAEQXOTWm/z1JQtTmowP2cgYgw= X-Google-Smtp-Source: AJdET5eoE+lxKH/P5tozej9Nf1Pyo3erWPejeDdjsmsCnZLcmfh0jNTJir3bywDBNIMe9iB7fseJmA== X-Received: by 2002:adf:f38f:: with SMTP id m15mr7057624wro.111.1542314337833; Thu, 15 Nov 2018 12:38:57 -0800 (PST) Received: from localhost.Home ([2a02:c7d:9b5c:9b00:1a75:ff25:fe7f:eaba]) by smtp.gmail.com with ESMTPSA id j129-v6sm22555373wmb.47.2018.11.15.12.38.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Nov 2018 12:38:57 -0800 (PST) From: Garry McNulty To: linux-mtd@lists.infradead.org Subject: [PATCH] ubifs: fix memory leak on error condition Date: Thu, 15 Nov 2018 20:38:50 +0000 Message-Id: <20181115203850.5774-1-garrmcnu@gmail.com> X-Mailer: git-send-email 2.9.5 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181115_123911_469077_90140059 X-CRM114-Status: GOOD ( 11.72 ) X-Spam-Score: 0.4 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (0.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.6 HK_RANDOM_ENVFROM Envelope sender username looks random -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:443 listed in] [list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (garrmcnu[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -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 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dedekind1@gmail.com, richard@nod.at, s.hauer@pengutronix.de, adrian.hunter@intel.com, linux-kernel@vger.kernel.org, Garry McNulty MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 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;