lkml.org 
[lkml]   [2013]   [Dec]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] 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.

Signed-off-by: Rui Xiang <rui.xiang@huawei.com>
---
fs/sysfs/symlink.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
index 3ae3f1b..d69b786 100644
--- a/fs/sysfs/symlink.c
+++ b/fs/sysfs/symlink.c
@@ -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;
}

--
1.8.2.2


\
 
 \ /
  Last update: 2013-12-03 03:21    [W:0.053 / U:0.128 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site