On 02/06/2021 14:30, Ming Lei wrote:
When scsi_add_host_with_dma() return failure, the caller will call scsi_host_put(shost) to release everything allocated for this host instance. So we can't free allocated stuff in scsi_add_host_with_dma(), otherwise double free will be caused. Strictly speaking, these host resources allocation should have been moved to scsi_host_alloc(), but the allocation may need driver's info which can be built between calling scsi_host_alloc() and scsi_add_host(), so just keep the allocations in scsi_add_host_with_dma(). Fixes the problem by relying on host device's release handler to release everything. Cc: Bart Van Assche<bvanassche@xxxxxxx> Cc: John Garry<john.garry@xxxxxxxxxx> Cc: Hannes Reinecke<hare@xxxxxxx> Signed-off-by: Ming Lei<ming.lei@xxxxxxxxxx>
Reviewed-by: John Garry <john.garry@xxxxxxxxxx>