mpi3mr: fix a double free
Subsystems (2)
PATCH 1/1 mpi3mr: fix a double free
Fix a double free, scsi_tgt_priv_data will be freed in mpi3mr_target_destroy.
I've also removed a second init of starget->hostdata with the same value.
Signed-off-by Tomas Henzl <[email protected]>
--- drivers/scsi/mpi3mr/mpi3mr_os.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/scsi/mpi3mr/mpi3mr_os.c +1 -4
@@ -3300,7 +3300,6 @@ static int mpi3mr_target_alloc(struct scsi_target *starget)spin_lock_irqsave (&mrioc->tgtdev_lock, flags); tgt_dev =__mpi3mr_get_tgtdev_by_perst_id (mrioc, starget->id);if (tgt_dev && !tgt_dev->is_hidden) { - starget->hostdata = scsi_tgt_priv_data; scsi_tgt_priv_data->starget = starget; scsi_tgt_priv_data->dev_handle = tgt_dev->dev_handle; scsi_tgt_priv_data->perst_id = tgt_dev->perst_id;
@@ -3309,10 +3308,8 @@ static int mpi3mr_target_alloc(struct scsi_target *starget) tgt_dev->starget = starget;atomic_set (&scsi_tgt_priv_data->block_io,0 ); retval =0 ; - }else { -kfree (scsi_tgt_priv_data); + }else retval = -ENXIO ; - }spin_unlock_irqrestore (&mrioc->tgtdev_lock, flags);return retval;
Signature · 1 line
2.31.1
Kashyap Desai
maintainerQuoted 8 lines
-----Original Message-----
From: Tomas Henzl [mailto:[email protected]]
Sent: Friday, June 4, 2021 11:56 PM
To: [email protected]
Cc: [email protected]; [email protected]
Subject: [PATCH] mpi3mr: fix a double freeFix a double free,
scsi_tgt_priv_datawill be freed in
mpi3mr_target_destroy.
Quoted 1 line
I've also removed a second init of
starget->hostdatawith the same
value.
Quoted 1 line
Tomas -
Patch looks good. We can also include below changes on top of your current patch.
drivers/scsi/mpi3mr/mpi3mr_os.c +0 -0
@@ -3293,10 +3293,6 @@ static int mpi3mr_target_alloc(struct scsi_target
*starget)
if (!scsi_tgt_priv_data)
return -ENOMEM;- starget->hostdata = scsi_tgt_priv_data;
- scsi_tgt_priv_data->starget = starget;
- scsi_tgt_priv_data->dev_handle = MPI3MR_INVALID_DEV_HANDLE;
-
spin_lock_irqsave(&mrioc->tgtdev_lock, flags);
tgt_dev = __mpi3mr_get_tgtdev_by_perst_id(mrioc, starget->id);
if (tgt_dev && !tgt_dev->is_hidden) {