]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
hfsplus: fix error processing issue in hfs_bmap_free()
authorViacheslav Dubeyko <slava@dubeyko.com>
Fri, 3 Apr 2026 23:05:53 +0000 (16:05 -0700)
committerViacheslav Dubeyko <slava@dubeyko.com>
Wed, 8 Apr 2026 21:23:29 +0000 (14:23 -0700)
Currently, we check only -EINVAL error code in hfs_bmap_free()
after calling the hfs_bmap_clear_bit(). It means that other
error codes will be silently ignored. This patch adds the checking
of all other error codes.

cc: Shardul Bankar <shardul.b@mpiricsoftware.com>
cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
cc: Yangtao Li <frank.li@vivo.com>
cc: linux-fsdevel@vger.kernel.org
Signed-off-by: Viacheslav Dubeyko <slava@dubeyko.com>
Link: https://lore.kernel.org/r/20260403230556.614171-3-slava@dubeyko.com
Signed-off-by: Viacheslav Dubeyko <slava@dubeyko.com>
fs/hfsplus/btree.c

index f1ed7c3365939e116d42dd331010c18300f2e5cc..80aa816ae1c0288bdff34bc95485f00aae8fb92c 100644 (file)
@@ -146,8 +146,9 @@ struct hfs_bmap_ctx {
  * Returns the struct page pointer, or an ERR_PTR on failure.
  * Note: The caller is responsible for mapping/unmapping the returned page.
  */
-static struct page *hfs_bmap_get_map_page(struct hfs_bnode *node, struct hfs_bmap_ctx *ctx,
-                               u32 byte_offset)
+static struct page *hfs_bmap_get_map_page(struct hfs_bnode *node,
+                                         struct hfs_bmap_ctx *ctx,
+                                         u32 byte_offset)
 {
        u16 rec_idx, off16;
        unsigned int page_off;
@@ -647,9 +648,12 @@ void hfs_bmap_free(struct hfs_bnode *node)
 
        res = hfs_bmap_clear_bit(node, nidx);
        if (res == -EINVAL) {
-               pr_crit("trying to free free bnode %u(%d)\n",
-                               node->this, node->type);
-       } else if (!res) {
+               pr_crit("trying to free the freed bnode %u(%d)\n",
+                       nidx, node->type);
+       } else if (res) {
+               pr_crit("fail to free bnode %u(%d)\n",
+                       nidx, node->type);
+       } else {
                tree->free_nodes++;
                mark_inode_dirty(tree->inode);
        }