Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp3499329ybl; Mon, 19 Aug 2019 20:27:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqzy4S4ao2g2/bHjxTxOM5yorgJrnACokZkr1vIOAPXbGwY+/3Nfn14PyK6xfFsN53FqYw5z X-Received: by 2002:a63:cc14:: with SMTP id x20mr23107285pgf.142.1566271628159; Mon, 19 Aug 2019 20:27:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566271628; cv=none; d=google.com; s=arc-20160816; b=ABwQk61WfUG/gUFy6k7DBtIsuHZkpcripW9XgjPUJszH4iqFa6BTgVP5f6rB0HZkYC n5gGlVktjJoLm2PksCDmS3vFIFPzQbv8WiaN6UrhqrUIv5K+avuVEwEVNKMpaBq3LZgI iywc5+jhrrGHOhCwg/PufNxNH/INb37jzaJdDECE8mLe4Pz+JnKgCL0ZPS2Bd4Q5Z0Hs v01FgoFsNwONxHFypYa0H0JwoOAeavBzu4aZ3Ff3OuRkZloZMKKApFCeNt5qANrKJQFW P3FHYySoAAS12LcMM1lANA5ac9rW6OvLTsb4itYokURbdCgVTNOyQ8B1skjrJ6yFGB7d DXqA== 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=4PBL1bXvyffgnqpG9faUgGd+kgjbdB5K1WLVO2WjDew=; b=gN3SM17MgpsG1MvBFv5y7Xuk6pzDMYNmcmTm9h1ZTrXCv0R1td9bWuYbuRaDhmQnib OGD6cGbsYBvfot/AlfAfE728GmnW4f7/8RliuMiU7cm+qFyVb3zudfwRU9DtQsSXaFze UfOWDzvpRIUhL1gBDmGjFJqmI2UOQ/9aAoQwkbwdFtUdssaKMrThYOuW5eZYGw9bIiow 25/hvdGcOoyqyrceQtpugcZ5/taOElgBv0i215cEtYehHs4UdzFWEQbAC2IB4mN3cbii byR0Pvi1IL4+gHwSrWTMLhCUVJC9X+FVUWLjHurZ/12i74uH5ltANbx5tf2PahhGiJpC gmPA== 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 j4si11064434pgq.375.2019.08.19.20.26.53; Mon, 19 Aug 2019 20:27:08 -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 S1729047AbfHTDY5 (ORCPT + 99 others); Mon, 19 Aug 2019 23:24:57 -0400 Received: from mail-yb1-f195.google.com ([209.85.219.195]:45584 "EHLO mail-yb1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728627AbfHTDY5 (ORCPT ); Mon, 19 Aug 2019 23:24:57 -0400 Received: by mail-yb1-f195.google.com with SMTP id u32so1444787ybi.12 for ; Mon, 19 Aug 2019 20:24:56 -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=4PBL1bXvyffgnqpG9faUgGd+kgjbdB5K1WLVO2WjDew=; b=GUBytnQtvYblaKV2zZRWWVQcBxrJpYIkERwgzfTea6kYifhPNx73DwpNoml1u74an0 m/QSp3plmdxjmuokRqSyeJ9mGFqlEfGHM8Tru9cwcN+1aCR2cK8dFTplhmJlNbHaBPnX 8GgBZ4JoGVoKfJTEcxbFyaU031PTtKcELRDvEs+6R4Rw5ApgMOkmGHMOWCvpwu1d3NT9 8V9eIhMuN4STTuUkDcJ2I28U4ifCYanAKkVZMvSV6d3zobZ7UslBc8p1ysNAJIWQsGiY cNpW3JFRX+E1rVRo056697qSYCPfWVVZoDYGNxFqM6yXbddUpr4c/lE33H2N2IE9xnQo N8eA== X-Gm-Message-State: APjAAAW+rynsN9fnat1ozMIFkWFzysBeXn09xkufvUCIaPTLnTIOIdCH tUX+gXMAYKXFRZ2yiST+LtsGhi+JpG3zfw== X-Received: by 2002:a25:324b:: with SMTP id y72mr6698233yby.361.1566271496511; Mon, 19 Aug 2019 20:24:56 -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 t63sm3433010ywe.103.2019.08.19.20.24.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 19 Aug 2019 20:24:55 -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:24:50 -0500 Message-Id: <1566271490-8533-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 __ubifs_node_verify_hmac(), 'hmac' is allocated through kmalloc(). However, it is not deallocated in the following execution if ubifs_node_calc_hmac() fails, leading to a memory leak bug. To fix this issue, free 'hmac' before returning the error. Signed-off-by: Wenwen Wang --- fs/ubifs/auth.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/ubifs/auth.c b/fs/ubifs/auth.c index d9af2de..8cdbd53 100644 --- a/fs/ubifs/auth.c +++ b/fs/ubifs/auth.c @@ -479,8 +479,10 @@ int __ubifs_node_verify_hmac(const struct ubifs_info *c, const void *node, return -ENOMEM; err = ubifs_node_calc_hmac(c, node, len, ofs_hmac, hmac); - if (err) + if (err) { + kfree(hmac); return err; + } err = crypto_memneq(hmac, node + ofs_hmac, hmac_len); -- 2.7.4