]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
cifs_get_link(): bail out in unsafe case
authorAl Viro <viro@zeniv.linux.org.uk>
Wed, 20 Sep 2023 02:28:16 +0000 (22:28 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Sun, 25 Feb 2024 07:10:32 +0000 (02:10 -0500)
->d_revalidate() bails out there, anyway.  It's not enough
to prevent getting into ->get_link() in RCU mode, but that
could happen only in a very contrieved setup.  Not worth
trying to do anything fancy here unless ->d_revalidate()
stops kicking out of RCU mode at least in some cases.

Reviewed-by: Christian Brauner <brauner@kernel.org>
Acked-by: Miklos Szeredi <mszeredi@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/smb/client/cifsfs.c

index e902de4e475af9cc3483fba922a1b11cbb068cd9..630e74628dfed6b20611415328f42065313429d0 100644 (file)
@@ -1172,6 +1172,9 @@ const char *cifs_get_link(struct dentry *dentry, struct inode *inode,
 {
        char *target_path;
 
+       if (!dentry)
+               return ERR_PTR(-ECHILD);
+
        target_path = kmalloc(PATH_MAX, GFP_KERNEL);
        if (!target_path)
                return ERR_PTR(-ENOMEM);