diff options
| author | Andrew Goodbody <[email protected]> | 2025-10-03 11:42:50 +0100 |
|---|---|---|
| committer | Heiko Schocher <[email protected]> | 2025-10-08 11:35:47 +0200 |
| commit | d23ddd5dee570e625e0fd76bba1e155f4cc1248c (patch) | |
| tree | 6421936aacc603cc409557bbbf117b8bd6f7fc38 /fs | |
| parent | 2bc0837ce19c64af44ccb912fc9c9e3a52269dec (diff) | |
fs: ubifs: Ensure buf is freed before return
Returning directly after buf has been allocated will result in a memory
leak. Instead set the error code and goto the common unwind code to
ensure that buf will be freed before returning.
This issue was found by Smatch.
Signed-off-by: Andrew Goodbody <[email protected]>
Diffstat (limited to 'fs')
| -rw-r--r-- | fs/ubifs/lprops.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/fs/ubifs/lprops.c b/fs/ubifs/lprops.c index a9e22abe6b4..74beb853b6e 100644 --- a/fs/ubifs/lprops.c +++ b/fs/ubifs/lprops.c @@ -1096,14 +1096,16 @@ static int scan_check_cb(struct ubifs_info *c, lst->empty_lebs += 1; lst->total_free += c->leb_size; lst->total_dark += ubifs_calc_dark(c, c->leb_size); - return LPT_SCAN_CONTINUE; + ret = LPT_SCAN_CONTINUE; + goto out; } if (lp->free + lp->dirty == c->leb_size && !(lp->flags & LPROPS_INDEX)) { lst->total_free += lp->free; lst->total_dirty += lp->dirty; lst->total_dark += ubifs_calc_dark(c, c->leb_size); - return LPT_SCAN_CONTINUE; + ret = LPT_SCAN_CONTINUE; + goto out; } sleb = ubifs_scan(c, lnum, 0, buf, 0); |
