• Stefan Haberland's avatar
    s390/dasd: fix list corruption of pavgroup group list · 0ede91f8
    Stefan Haberland authored
    dasd_alias_add_device() moves devices to the active_devices list in case
    of a scheduled LCU update regardless if they have previously been in a
    pavgroup or not.
    
    Example: device A and B are in the same pavgroup.
    
    Device A has already been in a pavgroup and the private->pavgroup pointer
    is set and points to a valid pavgroup. While going through dasd_add_device
    it is moved from the pavgroup to the active_devices list.
    
    In parallel device B might be removed from the same pavgroup in
    remove_device_from_lcu() which in turn checks if the group is empty
    and deletes it accordingly because device A has already been removed from
    there.
    
    When now device A enters remove_device_from_lcu() it is tried to remove it
    from the pavgroup again because the pavgroup pointer is still set and again
    the empty group will be cleaned up which leads to a list corruption.
    
    Fix by setting private->pavgroup to NULL in dasd_add_device.
    
    If the device has been the last device on the pavgroup an empty pavgroup
    remains but this will be cleaned up by the scheduled lcu_update which
    iterates over all existing pavgroups.
    
    Fixes: 8e09f215 ("[S390] dasd: add hyper PAV support to DASD device driver, part 1")
    Cc: stable@vger.kernel.org
    Signed-off-by: default avatarStefan Haberland <sth@linux.ibm.com>
    Reviewed-by: default avatarJan Hoeppner <hoeppner@linux.ibm.com>
    Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
    0ede91f8
dasd_alias.c 27.7 KB