]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ksmbd: fix n.data memory leak in ksmbd_vfs_set_dos_attrib_xattr
authorQiang Liu <liuqiang@kylinos.cn>
Wed, 24 Jun 2026 01:13:20 +0000 (09:13 +0800)
committerSteve French <stfrench@microsoft.com>
Wed, 1 Jul 2026 02:29:45 +0000 (21:29 -0500)
Free ndr buffer data when ndr_encode_dos_attr() returns error
to avoid memory leak.

Signed-off-by: Qiang Liu <liuqiang@kylinos.cn>
Reviewed-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/server/vfs.c

index 6528412eac2db50ba5c993558476b46ac4870ac8..d0a0ad15d80376af75582497d24fc441eeb01725 100644 (file)
@@ -1575,14 +1575,15 @@ int ksmbd_vfs_set_dos_attrib_xattr(struct mnt_idmap *idmap,
 
        err = ndr_encode_dos_attr(&n, da);
        if (err)
-               return err;
+               goto out;
 
        err = ksmbd_vfs_setxattr(idmap, path, XATTR_NAME_DOS_ATTRIBUTE,
                                 (void *)n.data, n.offset, 0, get_write);
        if (err)
                ksmbd_debug(SMB, "failed to store dos attribute in xattr\n");
-       kfree(n.data);
 
+out:
+       kfree(n.data);
        return err;
 }