• Rajat Jain's avatar
    sysfs: Fix internal_create_group() for named group updates · c855cf27
    Rajat Jain authored
    
    
    There are a couple of problems with named group updates in the code
    today:
    
    * sysfs_update_group() will always fail for a named group, because
      internal_create_group() will try to create a new sysfs directory
      unconditionally, which will ofcourse fail with -EEXIST.
    
    * We can leak the kernfs_node for grp->name if some one tries to:
      - rename a group (change grp->name), or
      - update a named group, to an unnamed group
    
    It appears that the whole purpose of sysfs_update_group() was to
    allow changing the permissions or visibility of attributes and not
    the names. So make it clear in the comments, and allow it to update
    an existing named group.
    Signed-off-by: default avatarRajat Jain <rajatja@google.com>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    c855cf27
group.c 11.2 KB