sysfs: add necessary Null check in sysfs_do_create_link_sd
PATCH 1/1 sysfs: add necessary Null check in sysfs_do_create_link_sd
While target_sd or sd are null, it won't need sysfs_put and should return -ENOENT directly. Here add null check for target_sd and sd.
--- fs/sysfs/symlink.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
fs/sysfs/symlink.c +4 -2
@@ -83,8 +83,10 @@ static int sysfs_do_create_link_sd(struct sysfs_dirent *parent_sd,return 0 ; out_put: -sysfs_put (target_sd); -sysfs_put (sd); +if (target_sd) +sysfs_put (target_sd); +if (sd) +sysfs_put (sd);return error; }
Signature · 1 line
1.8.2.2
Greg Kroah-Hartman
maintainerQuoted 14 lines · Rui Xiang
While
target_sdor sd are null, it won't needsysfs_putand should return-ENOENTdirectly. Here add null check fortarget_sdand sd.Signed-off-by Rui Xiang <[email protected]>--- fs/sysfs/symlink.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)fs/sysfs/symlink.c +0
-0
fs/sysfs/symlink.c static int sysfs_do_create_link_sd(struct sysfs_dirent *parent_sd, · line 89
Quoted 9 lines
fs/sysfs/symlink.c +4
-2@@ -83,8 +83,10 @@ static int sysfs_do_create_link_sd(struct sysfs_dirent *parent_sd,return 0 ; out_put: -sysfs_put (target_sd); -sysfs_put (sd); +if (target_sd) +sysfs_put (target_sd); +if (sd) +sysfs_put (sd);
This change does nothing at all, why is it needed?
greg k-h
Quoted 17 lines · Greg Kroah-Hartman
Quoted 16 lines · Rui Xiang
While
target_sdor sd are null, it won't needsysfs_putand should return-ENOENTdirectly. Here add null check fortarget_sdand sd.Signed-off-by Rui Xiang <[email protected]>--- fs/sysfs/symlink.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)fs/sysfs/symlink.c +0
-0@@ -83,8 +83,10 @@ static int sysfs_do_create_link_sd(struct sysfs_dirent *parent_sd,return 0 ;
Quoted 10 lines
fs/sysfs/symlink.c static int sysfs_do_create_link_sd(struct sysfs_dirent *parent_sd, · line 89
Quoted 7 lines
fs/sysfs/symlink.c +4
-2out_put: -sysfs_put (target_sd); -sysfs_put (sd); +if (target_sd) +sysfs_put (target_sd); +if (sd) +sysfs_put (sd);This change does nothing at all, why is it needed?
oh, I noted sysfs_put has a null check. So these are unnecessary. Sorry, please ignore it.
Thanks,
Rui