Commit b12bb60d authored by Ales Novak's avatar Ales Novak Committed by James Bottomley

[SCSI] storvsc: NULL pointer dereference fix

If the initialization of storvsc fails, the storvsc_device_destroy()
causes NULL pointer dereference.

storvsc_bus_scan()
  scsi_scan_target()
    __scsi_scan_target()
      scsi_probe_and_add_lun(hostdata=NULL)
        scsi_alloc_sdev(hostdata=NULL)

	  sdev->hostdata = hostdata

	  now the host allocation fails

          __scsi_remove_device(sdev)

	  calls sdev->host->hostt->slave_destroy() ==
	  storvsc_device_destroy(sdev)
	    access of sdev->hostdata->request_mempool
Signed-off-by: default avatarAles Novak <alnovak@suse.cz>
Signed-off-by: default avatarThomas Abraham <tabraham@suse.com>
Reviewed-by: default avatarJiri Kosina <jkosina@suse.cz>
Acked-by: default avatarK. Y. Srinivasan <kys@microsoft.com>
Cc: stable@vger.kernel.org
Signed-off-by: default avatarJames Bottomley <JBottomley@Parallels.com>
parent b77ed25c
...@@ -1419,6 +1419,9 @@ static void storvsc_device_destroy(struct scsi_device *sdevice) ...@@ -1419,6 +1419,9 @@ static void storvsc_device_destroy(struct scsi_device *sdevice)
{ {
struct stor_mem_pools *memp = sdevice->hostdata; struct stor_mem_pools *memp = sdevice->hostdata;
if (!memp)
return;
mempool_destroy(memp->request_mempool); mempool_destroy(memp->request_mempool);
kmem_cache_destroy(memp->request_pool); kmem_cache_destroy(memp->request_pool);
kfree(memp); kfree(memp);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment