Skip to contentSkip to conversation

inotify: Fix error return code assignment flow.

PATCH In review youngjun 2 participants 2 messages Apr 26, 2020 – Apr 27, 2020

Subsystems (3)
lore
Share & tools
lore

youngjun

author
#0 lore raw

PATCH 1/1 inotify: Fix error return code assignment flow.

If error code is initialized -EINVAL, there is no need to assign -EINVAL.

---
 fs/notify/inotify/inotify_user.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
fs/notify/inotify/inotify_user.c +1 -3
index 81ffc8629fc4..f88bbcc9efeb 100644
@@ -764,20 +764,18 @@ SYSCALL_DEFINE2(inotify_rm_watch, int, fd, __s32, wd)
 	struct fsnotify_group *group;
 	struct inotify_inode_mark *i_mark;
 	struct fd f;
-	int ret = 0;
+	int ret = -EINVAL;
 
 	f = fdget(fd);
 	if (unlikely(!f.file))
 		return -EBADF;
 
 	/* verify that this is indeed an inotify instance */
-	ret = -EINVAL;
 	if (unlikely(f.file->f_op != &inotify_fops))
 		goto out;
 
 	group = f.file->private_data;
 
-	ret = -EINVAL;
 	i_mark = inotify_idr_find(group, wd);
 	if (unlikely(!i_mark))
 		goto out;
Signature · 1 line
2.17.1
maintainer
#1 lore raw
Quoted 3 lines · youngjun

If error code is initialized -EINVAL, there is no need to assign -EINVAL.

Thanks. I've added the cleanup to my tree,

Honza

Quoted 33 lines
---
 fs/notify/inotify/inotify_user.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
fs/notify/inotify/inotify_user.c +1 -3
index 81ffc8629fc4..f88bbcc9efeb 100644
@@ -764,20 +764,18 @@ SYSCALL_DEFINE2(inotify_rm_watch, int, fd, __s32, wd)
 	struct fsnotify_group *group;
 	struct inotify_inode_mark *i_mark;
 	struct fd f;
-	int ret = 0;
+	int ret = -EINVAL;
 
 	f = fdget(fd);
 	if (unlikely(!f.file))
 		return -EBADF;
 
 	/* verify that this is indeed an inotify instance */
-	ret = -EINVAL;
 	if (unlikely(f.file->f_op != &inotify_fops))
 		goto out;
 
 	group = f.file->private_data;
 
-	ret = -EINVAL;
 	i_mark = inotify_idr_find(group, wd);
 	if (unlikely(!i_mark))
 		goto out;
Signature · 1 line
2.17.1
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR