mstack: fix resource leak on failure path
This makes the mstack_load() requires 'ret', as clearing the loaded
mstack without use is meaningless. All callers already pass non-NULL for
the argument.
Follow-up for 8343032a86.
Fixes CID#1645105.
This commit is contained in:
+5
-8
@@ -1120,19 +1120,18 @@ int mstack_apply(
|
||||
return mstack_bind_mounts(&mstack, where, /* where_fd= */ -EBADF, flags, ret_root_fd);
|
||||
}
|
||||
|
||||
int mstack_load(const char *dir,
|
||||
int dir_fd,
|
||||
MStack **ret) {
|
||||
|
||||
int mstack_load(const char *dir, int dir_fd, MStack **ret) {
|
||||
int r;
|
||||
|
||||
assert(ret);
|
||||
|
||||
/* Well-known errors:
|
||||
*
|
||||
* -ENOTUNIQ → Multiple conflicting layers for the same path defined
|
||||
* -EBADMSG → Bad file suffix, inode type for layer, or unrecognized entry
|
||||
*/
|
||||
|
||||
MStack *mstack = new(MStack, 1);
|
||||
_cleanup_(mstack_freep) MStack *mstack = new(MStack, 1);
|
||||
if (!mstack)
|
||||
return -ENOMEM;
|
||||
|
||||
@@ -1142,9 +1141,7 @@ int mstack_load(const char *dir,
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (ret)
|
||||
*ret = TAKE_PTR(mstack);
|
||||
|
||||
*ret = TAKE_PTR(mstack);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user