Several fixlets for issues found by Coverity (#40765)

This commit is contained in:
Yu Watanabe
2026-02-20 19:13:37 +09:00
committed by GitHub
3 changed files with 23 additions and 13 deletions
+4 -1
View File
@@ -101,7 +101,10 @@ static OciLayerState* oci_layer_state_free(OciLayerState *st) {
pidref_done_sigkill_wait(&st->tar_pid);
if (st->temp_path) {
import_remove_tree(st->temp_path, st->pull ? &st->pull->userns_fd : NULL, st->pull->flags);
import_remove_tree(
st->temp_path,
st->pull ? &st->pull->userns_fd : NULL,
st->pull ? st->pull->flags : 0);
free(st->temp_path);
}
free(st->final_path);
+7 -10
View File
@@ -56,7 +56,7 @@ static void mstack_done(MStack *mstack) {
safe_close(mstack->usr_mount_fd);
}
MStack *mstack_free(MStack *mstack) {
MStack* mstack_free(MStack *mstack) {
if (!mstack)
return NULL;
@@ -501,7 +501,7 @@ static bool mount_is_ro(MStackMount *m, MStackFlags flags) {
IN_SET(m->mount_type, MSTACK_LAYER, MSTACK_ROBIND);
}
static const char *mount_name(MStackMount *m) {
static const char* mount_name(MStackMount *m) {
assert(m);
/* Returns some vaguely useful identifier for this layer, for showing in debug output */
@@ -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;
}
+12 -2
View File
@@ -47,7 +47,7 @@ typedef struct MStack {
.usr_mount_fd = -EBADF, \
}
MStack *mstack_free(MStack *mstack);
MStack* mstack_free(MStack *mstack);
DEFINE_TRIVIAL_CLEANUP_FUNC(MStack*, mstack_free);
int mstack_load(const char *dir, int dir_fd, MStack **ret);
@@ -56,7 +56,17 @@ int mstack_make_mounts(MStack *mstack, const char *temp_mount_dir, MStackFlags f
int mstack_bind_mounts(MStack *mstack, const char *where, int where_fd, MStackFlags flags, int *ret_root_fd);
/* The four calls above in one */
int mstack_apply(const char *dir, int dir_fd, const char *where, const char *temp_mount_dir, sd_varlink *mountfsd_link, int userns_fd, const ImagePolicy *image_policy, const ImageFilter *image_filter, MStackFlags flags, int *ret_root_fd);
int mstack_apply(
const char *dir,
int dir_fd,
const char *where,
const char *temp_mount_dir,
sd_varlink *mountfsd_link,
int userns_fd,
const ImagePolicy *image_policy,
const ImageFilter *image_filter,
MStackFlags flags,
int *ret_root_fd);
int mstack_is_read_only(MStack *mstack);
int mstack_is_foreign_uid_owned(MStack *mstack);