mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Zhipeng Lu <alexious@zju.edu.cn>
To: alexious@zju.edu.cn
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Desmond Cheong Zhi Xi <desmondcheongzx@gmail.com>,
	Viacheslav Dubeyko <slava@dubeyko.com>,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] hfs: fix a memleak in hfs_find_init
Date: Tue, 23 Jan 2024 01:27:17 +0800	[thread overview]
Message-ID: <20240122172719.3843098-1-alexious@zju.edu.cn> (raw)

When the switch statment goes to default and return an error, ptr should
be freed since it is allocated in hfs_find_init.

Fixes: b3b2177a2d79 ("hfs: add lock nesting notation to hfs_find_init")
Signed-off-by: Zhipeng Lu <alexious@zju.edu.cn>
---
 fs/hfs/bfind.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/hfs/bfind.c b/fs/hfs/bfind.c
index ef9498a6e88a..7aa3b9aba4d1 100644
--- a/fs/hfs/bfind.c
+++ b/fs/hfs/bfind.c
@@ -36,6 +36,7 @@ int hfs_find_init(struct hfs_btree *tree, struct hfs_find_data *fd)
 		mutex_lock_nested(&tree->tree_lock, ATTR_BTREE_MUTEX);
 		break;
 	default:
+		kfree(fd->search_key);
 		return -EINVAL;
 	}
 	return 0;
-- 
2.34.1


             reply	other threads:[~2024-01-22 17:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-22 17:27 Zhipeng Lu [this message]
2024-01-26 15:02 ` Viacheslav Dubeyko
2024-01-29 12:54   ` alexious
2024-01-29 14:25     ` Viacheslav Dubeyko
2024-01-29 15:17       ` alexious

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240122172719.3843098-1-alexious@zju.edu.cn \
    --to=alexious@zju.edu.cn \
    --cc=akpm@linux-foundation.org \
    --cc=desmondcheongzx@gmail.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=slava@dubeyko.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®