]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
zynqmp: don't bother with debugfs_file_{get,put}() in proxied fops
authorAl Viro <viro@zeniv.linux.org.uk>
Wed, 2 Jul 2025 21:14:08 +0000 (22:14 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 9 Jul 2025 11:30:28 +0000 (13:30 +0200)
When debugfs file has been created by debugfs_create_file_unsafe(),
we do need the file_operations methods to use debugfs_file_{get,put}()
to prevent concurrent removal; for files created by debugfs_create_file()
that is done in the wrappers that call underlying methods, so there's
no point whatsoever duplicating that in the underlying methods themselves.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Link: https://lore.kernel.org/r/20250702211408.GA3406663@ZenIV
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/gpu/drm/xlnx/zynqmp_dp.c

index 238cbb49963efa6e8cc737d8a6e76250f6531276..197defe4f928ce48bf725eef68431b4382507f35 100644 (file)
@@ -1869,20 +1869,14 @@ static int zynqmp_dp_test_setup(struct zynqmp_dp *dp)
 static ssize_t zynqmp_dp_pattern_read(struct file *file, char __user *user_buf,
                                      size_t count, loff_t *ppos)
 {
-       struct dentry *dentry = file->f_path.dentry;
        struct zynqmp_dp *dp = file->private_data;
        char buf[16];
        ssize_t ret;
 
-       ret = debugfs_file_get(dentry);
-       if (unlikely(ret))
-               return ret;
-
        scoped_guard(mutex, &dp->lock)
                ret = snprintf(buf, sizeof(buf), "%s\n",
                               test_pattern_str[dp->test.pattern]);
 
-       debugfs_file_put(dentry);
        return simple_read_from_buffer(user_buf, count, ppos, buf, ret);
 }
 
@@ -1890,27 +1884,20 @@ static ssize_t zynqmp_dp_pattern_write(struct file *file,
                                       const char __user *user_buf,
                                       size_t count, loff_t *ppos)
 {
-       struct dentry *dentry = file->f_path.dentry;
        struct zynqmp_dp *dp = file->private_data;
        char buf[16];
        ssize_t ret;
        int pattern;
 
-       ret = debugfs_file_get(dentry);
-       if (unlikely(ret))
-               return ret;
-
        ret = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, user_buf,
                                     count);
        if (ret < 0)
-               goto out;
+               return ret;
        buf[ret] = '\0';
 
        pattern = sysfs_match_string(test_pattern_str, buf);
-       if (pattern < 0) {
-               ret = -EINVAL;
-               goto out;
-       }
+       if (pattern < 0)
+               return -EINVAL;
 
        mutex_lock(&dp->lock);
        dp->test.pattern = pattern;
@@ -1919,8 +1906,6 @@ static ssize_t zynqmp_dp_pattern_write(struct file *file,
                                                 dp->test.custom) ?: ret;
        mutex_unlock(&dp->lock);
 
-out:
-       debugfs_file_put(dentry);
        return ret;
 }
 
@@ -2026,20 +2011,13 @@ DEFINE_DEBUGFS_ATTRIBUTE(fops_zynqmp_dp_active, zynqmp_dp_active_get,
 static ssize_t zynqmp_dp_custom_read(struct file *file, char __user *user_buf,
                                     size_t count, loff_t *ppos)
 {
-       struct dentry *dentry = file->f_path.dentry;
        struct zynqmp_dp *dp = file->private_data;
        ssize_t ret;
 
-       ret = debugfs_file_get(dentry);
-       if (unlikely(ret))
-               return ret;
-
        mutex_lock(&dp->lock);
        ret = simple_read_from_buffer(user_buf, count, ppos, &dp->test.custom,
                                      sizeof(dp->test.custom));
        mutex_unlock(&dp->lock);
-
-       debugfs_file_put(dentry);
        return ret;
 }
 
@@ -2047,18 +2025,13 @@ static ssize_t zynqmp_dp_custom_write(struct file *file,
                                      const char __user *user_buf,
                                      size_t count, loff_t *ppos)
 {
-       struct dentry *dentry = file->f_path.dentry;
        struct zynqmp_dp *dp = file->private_data;
        ssize_t ret;
        char buf[sizeof(dp->test.custom)];
 
-       ret = debugfs_file_get(dentry);
-       if (unlikely(ret))
-               return ret;
-
        ret = simple_write_to_buffer(buf, sizeof(buf), ppos, user_buf, count);
        if (ret < 0)
-               goto out;
+               return ret;
 
        mutex_lock(&dp->lock);
        memcpy(dp->test.custom, buf, ret);
@@ -2066,9 +2039,6 @@ static ssize_t zynqmp_dp_custom_write(struct file *file,
                ret = zynqmp_dp_set_test_pattern(dp, dp->test.pattern,
                                                 dp->test.custom) ?: ret;
        mutex_unlock(&dp->lock);
-
-out:
-       debugfs_file_put(dentry);
        return ret;
 }