Need to free allocated buffer_head bh if __erofs_battach() fails.
Signed-off-by: Sandeep Dhavale <[email protected]>
---
lib/cache.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
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;
}
--
2.42.0.283.g2d96d420d3-goog