Skip to contentSkip to conversation

hfs: check return value before accessing fd in hfs_brec_find()

PATCH New Jeremy Cline 1 participant 1 message Nov 3, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hfs: check return value before accessing fd in hfs_brec_find()

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.

---
 fs/hfs/bfind.c | 2 ++
 1 file changed, 2 insertions(+)
fs/hfs/bfind.c +2 -0
index ef9498a6e88a..f225c78a9e66 100644
@@ -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)
Signature · 1 line
2.41.0