[Devel] [PATCH RHEL7 COMMIT] ve/sysfs: handle NULL sysfs_dirent in sysfs_next_entry()

Konstantin Khorenko khorenko at virtuozzo.com
Mon Jun 18 13:06:55 MSK 2018


The commit is pushed to "branch-rh7-3.10.0-693.21.1.vz7.50.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-693.21.1.vz7.50.11
------>
commit ca5aea989561f7ef4a2b2054f8d3c9cabe57023e
Author: Vasily Averin <vvs at virtuozzo.com>
Date:   Mon Jun 18 13:06:55 2018 +0300

    ve/sysfs: handle NULL sysfs_dirent in sysfs_next_entry()
    
    This patch fixes vz7 commit f9aed8d8fb35 ("VE/SYSFS: hide forbidden entries in container").
    It spitted sysfs_dir_next_pos() into few parts including creation of sysfs_next_entry().
    Originally this part of code worked correctly if sysfs_dir_pos had return NULL,
    however according check was lost during modification.
    
    This patch restores lost check, now sysfs_next_entry() will not crash if cur=NULL
    
    Fixes: f9aed8d8fb35 ("VE/SYSFS: hide forbidden entries in container")
    https://pmc.acronis.com/browse/VSTOR-11122
    
    Signed-off-by: Vasily Averin <vvs at virtuozzo.com>
---
 fs/sysfs/dir.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
index f9294c00b571..485d77b0d419 100644
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -1005,7 +1005,7 @@ static struct sysfs_dirent *sysfs_dir_pos(struct sysfs_dirent *parent_sd,
 
 static struct sysfs_dirent *sysfs_next_entry(struct sysfs_dirent *cur)
 {
-	struct rb_node *node = rb_next(&cur->s_rb);
+	struct rb_node *node = cur ? rb_next(&cur->s_rb) : NULL;
 
 	return node ? to_sysfs_dirent(node) : NULL;
 }


More information about the Devel mailing list