lkml.org 
[lkml]   [2013]   [Oct]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH] sysfs: move assignment to be under lock in sysfs_remove_dir()
Greg KH <gregkh@linuxfoundation.org> writes:

> From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>
> Linus noticed that the assignment of sd isn't protected by the lock in
> sysfs_remove_dir(), so move the assignment of the variable under the
> lock to be safe.
>
> Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Reviewed-by: "Eric W. Biederman" <ebiederm@xmission.com>

> ---
>
> Tejun, any objection to this patch? You consolidated the locks back in
> 2007 on this function, and nothing has changed there since then, so odds
> are it's not a problem, but nice to be safe, right?
>
> fs/sysfs/dir.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
> index eab59de4..2609f934 100644
> --- a/fs/sysfs/dir.c
> +++ b/fs/sysfs/dir.c
> @@ -856,9 +856,10 @@ void sysfs_remove(struct sysfs_dirent *sd)
> */
> void sysfs_remove_dir(struct kobject *kobj)
> {
> - struct sysfs_dirent *sd = kobj->sd;
> + struct sysfs_dirent *sd;
>
> spin_lock(&sysfs_assoc_lock);
> + sd = kobj->sd;
> kobj->sd = NULL;
> spin_unlock(&sysfs_assoc_lock);
>


\
 
 \ /
  Last update: 2013-10-30 23:21    [W:0.332 / U:0.032 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site