All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hfs: check return value before accessing fd in hfs_brec_find()
@ 2023-11-03 13:03 Jeremy Cline
  0 siblings, 0 replies; only message in thread
From: Jeremy Cline @ 2023-11-03 13:03 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel, Jeremy Cline, syzbot+5ce571007a695806e949

In the event that hfs_brec_keylen() fails, an error is returned to the
caller of __hfs_brec_find() and the struct hfs_find_data is not
initialized.

The result needs to be checked before attempting to read any fields from
fd.

Reported-by: syzbot+5ce571007a695806e949@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=5ce571007a695806e949
Signed-off-by: Jeremy Cline <jeremy@jcline.org>
---
 fs/hfs/bfind.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/hfs/bfind.c b/fs/hfs/bfind.c
index ef9498a6e88a..f225c78a9e66 100644
--- a/fs/hfs/bfind.c
+++ b/fs/hfs/bfind.c
@@ -136,6 +136,8 @@ int hfs_brec_find(struct hfs_find_data *fd)
 		bnode->parent = parent;
 
 		res = __hfs_brec_find(bnode, fd);
+		if (res < 0)
+			goto release;
 		if (!height)
 			break;
 		if (fd->record < 0)
-- 
2.41.0


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2023-11-03 13:04 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-03 13:03 [PATCH] hfs: check return value before accessing fd in hfs_brec_find() Jeremy Cline

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.