aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSandeep Dhavale <dhavale@google.com>2023-09-13 15:11:00 -0700
committerGao Xiang <hsiangkao@linux.alibaba.com>2023-09-14 10:53:38 +0800
commit8bd9ce65a0a5440af820554041229b9204828258 (patch)
treea82c72d446afa4e171e0baf3a833fa541aa68207
parentd069bab62e265a4731f761d8b7b2658466449589 (diff)
downloaderofs-utils-8bd9ce65a0a5440af820554041229b9204828258.tar.gz
erofs-utils: lib: Fix memory leak if __erofs_battach() fails
Need to free allocated buffer_head bh if __erofs_battach() fails. Signed-off-by: Sandeep Dhavale <dhavale@google.com> Link: https://lore.kernel.org/r/20230913221104.429825-4-dhavale@google.com Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
-rw-r--r--lib/cache.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/cache.c b/lib/cache.c
index 5205d57..a9948f0 100644
--- a/lib/cache.c
+++ b/lib/cache.c
@@ -282,8 +282,10 @@ struct erofs_buffer_head *erofs_balloc(int type, erofs_off_t size,
ret = __erofs_battach(bb, bh, size, alignsize,
required_ext + inline_ext, false);
- if (ret < 0)
+ if (ret < 0) {
+ free(bh);
return ERR_PTR(ret);
+ }
return bh;
}