public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sysfs: add necessary Null check in sysfs_do_create_link_sd
@ 2013-12-03  1:38 Rui Xiang
  2013-12-03  2:47 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 3+ messages in thread
From: Rui Xiang @ 2013-12-03  1:38 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-kernel

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] sysfs: add necessary Null check in sysfs_do_create_link_sd
  2013-12-03  1:38 [PATCH] sysfs: add necessary Null check in sysfs_do_create_link_sd Rui Xiang
@ 2013-12-03  2:47 ` Greg Kroah-Hartman
  2013-12-03  3:08   ` Rui Xiang
  0 siblings, 1 reply; 3+ messages in thread
From: Greg Kroah-Hartman @ 2013-12-03  2:47 UTC (permalink / raw)
  To: Rui Xiang; +Cc: linux-kernel

On Tue, Dec 03, 2013 at 09:38:47AM +0800, Rui Xiang wrote:
> 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);

This change does nothing at all, why is it needed?

greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] sysfs: add necessary Null check in sysfs_do_create_link_sd
  2013-12-03  2:47 ` Greg Kroah-Hartman
@ 2013-12-03  3:08   ` Rui Xiang
  0 siblings, 0 replies; 3+ messages in thread
From: Rui Xiang @ 2013-12-03  3:08 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-kernel

On 2013/12/3 10:47, Greg Kroah-Hartman wrote:
> On Tue, Dec 03, 2013 at 09:38:47AM +0800, Rui Xiang wrote:
>> 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);
> 
> 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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-12-03  3:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-03  1:38 [PATCH] sysfs: add necessary Null check in sysfs_do_create_link_sd Rui Xiang
2013-12-03  2:47 ` Greg Kroah-Hartman
2013-12-03  3:08   ` Rui Xiang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox