• Ming Lei's avatar
    scsi: core: Fix race on creating sense cache · f9b0530f
    Ming Lei authored
    When scsi_init_sense_cache(host) is called concurrently from different
    hosts, each code path may find that no cache has been created and
    allocate a new one. The lack of locking can lead to potentially
    overriding a cache allocated by a different host.
    
    Fix the issue by moving 'mutex_lock(&scsi_sense_cache_mutex)' before
    scsi_select_sense_cache().
    
    Fixes: 0a6ac4ee ("scsi: respect unchecked_isa_dma for blk-mq")
    Cc: Stable <stable@vger.kernel.org>
    Cc: Christoph Hellwig <hch@lst.de>
    Cc: Hannes Reinecke <hare@suse.com>
    Cc: Ewan D. Milne <emilne@redhat.com>
    Signed-off-by: default avatarMing Lei <ming.lei@redhat.com>
    Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
    f9b0530f
scsi_lib.c 80.5 KB