Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp3483586ybl; Mon, 19 Aug 2019 20:05:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqxb+UctQPAIRrKo3GwZnKZIJFV7Q3HDTHIxWelADyAendLLsyW+VhN1+ve4gc7fYXnyobFV X-Received: by 2002:a17:90a:148:: with SMTP id z8mr16313702pje.96.1566270304509; Mon, 19 Aug 2019 20:05:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566270304; cv=none; d=google.com; s=arc-20160816; b=TK/KCeYvb5SfzVHlFhzH//c3dBQUt3xUAbDKDqkq7+7OLRyE9zvrwhvohoiQC4ouol GbuVPccerSh3JjxwIvunCJdWmn1ajwaGevTPya5TOFrw013gndgeRTcEdhBmSnOB7Bp/ iDK3Z6AoGpFB08x0pUTYEDgrtEgsV2qWAJyZnMPr4lP1x2OJabc7NHO/uMafT3VWAcOh sP0hXDNYVN2kTknTEx545VxC/JhMnz1gGPGfvECbPqutVK1bBhn7csmWxQa5Bhk+E5ta NXojL7h3J0rSzqAgCJMU5piW9fhak6lLmHiWaumkcCzs8KvSNBYVOEGWMDWzwW5FQ4FZ +K6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=T/JaohmNZpvxoXfMBJgKQy6uqfXida8R0ifjCoHqJy4=; b=AA/JZu+8sKrcoIqHegztIB//oOlMvAuimGAqwaAbO6Tf4hGqt7R3RPnSLDxlN7Zsgv Lg1JtFz3cu/ugtMywL1gJTohZVoJgrNLyMjacg3b3N2lYl653t4x+DWWb1g459j0mXpn tbTHNGaXU4RWzEBfGVZo2v1oCAGCTiDAagdK/ZlPIEyPwQ4ox4BhrmGYX3rwQWhqtUf4 Kp2k7Fw39oJdXIRrjarllYjuIlL9DUiVq/L69v1s1J0AGC5FZF2SBUEHOpSEnxtgljzB Wf3t/w9RkEVP6h7S6JA9fI8qmcn8iD3zvwRarPR+P8qq0LJkIaXZ9F5wkAdf/mPJf4qN DMYQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a10si11836830pff.277.2019.08.19.20.04.48; Mon, 19 Aug 2019 20:05:04 -0700 (PDT) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728898AbfHTDDy (ORCPT + 99 others); Mon, 19 Aug 2019 23:03:54 -0400 Received: from mail-yb1-f193.google.com ([209.85.219.193]:33411 "EHLO mail-yb1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728719AbfHTDDy (ORCPT ); Mon, 19 Aug 2019 23:03:54 -0400 Received: by mail-yb1-f193.google.com with SMTP id b16so1433754ybq.0 for ; Mon, 19 Aug 2019 20:03:54 -0700 (PDT) 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=T/JaohmNZpvxoXfMBJgKQy6uqfXida8R0ifjCoHqJy4=; b=JVLgrcIx549+6wDPXUeFTUXgxQFuN0WCVMWoOPNzayLtaleCxy3hj5hwVK3/eMbHUh g8rQxj0VmaJdBmkzLIuxcLshsleO7vcqWeLZXlQ3AHe1I9wn5Llk6gjwBP34yTtSwqat FVMQou1kkuCF2oVwI2U8jCvvkAZeUB5YyTOfjrJZ7or4/5YNSk+ypvqYpEhFMMmujJKa IBbDQxPkXyAlEMBdz7QeLj4IccraXBA1QPAdK0RivoeG/xC+30g/VKS/z5WvM0ognrB7 NU8kCFj88CRMhUFEd/RU10NmC9AGpe9s85aJw0Z0Opocy9Me0zEtO+xNX+FWyzxa53L6 Hs9w== X-Gm-Message-State: APjAAAWeRSxEe+4IxwGAk3knSvHiqu+ttHprImKYzJ3SlKDiOtPpYHCd d/NI2X2xApHEPvs8NeuC0pM= X-Received: by 2002:a5b:7c8:: with SMTP id t8mr18452781ybq.113.1566270233627; Mon, 19 Aug 2019 20:03:53 -0700 (PDT) Received: from localhost.localdomain (24-158-240-219.dhcp.smyr.ga.charter.com. [24.158.240.219]) by smtp.gmail.com with ESMTPSA id z6sm3820879ywg.40.2019.08.19.20.03.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 19 Aug 2019 20:03:52 -0700 (PDT) From: Wenwen Wang To: Wenwen Wang Cc: Richard Weinberger , Artem Bityutskiy , Adrian Hunter , linux-mtd@lists.infradead.org (open list:UBI FILE SYSTEM (UBIFS)), linux-kernel@vger.kernel.org (open list) Subject: [PATCH] ubifs: fix a memory leak bug Date: Mon, 19 Aug 2019 22:03:46 -0500 Message-Id: <1566270227-8302-1-git-send-email-wenwen@cs.uga.edu> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In read_znode(), the indexing node 'idx' is allocated by kmalloc(). However, it is not deallocated in the following execution if ubifs_node_check_hash() fails, leading to a memory leak bug. To fix this issue, free 'idx' before returning the error. Signed-off-by: Wenwen Wang --- fs/ubifs/tnc_misc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/ubifs/tnc_misc.c b/fs/ubifs/tnc_misc.c index 6f293f6..49cb34c 100644 --- a/fs/ubifs/tnc_misc.c +++ b/fs/ubifs/tnc_misc.c @@ -284,6 +284,7 @@ static int read_znode(struct ubifs_info *c, struct ubifs_zbranch *zzbr, err = ubifs_node_check_hash(c, idx, zzbr->hash); if (err) { ubifs_bad_hash(c, idx, zzbr->hash, lnum, offs); + kfree(idx); return err; } -- 2.7.4