Skip to content

Commit b4c2554

Browse files
martinkpetersenJames Bottomley
authored andcommitted
[SCSI] Fix protection scsi_data_buffer leak
We would leak a scsi_data_buffer if the free_list command was of the protected variety. Reported-by: Boaz Harrosh <bharrosh@panasas.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> Cc: Stable Tree <stable@kernel.org> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
1 parent 35e1a5d commit b4c2554

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

drivers/scsi/scsi.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,10 +241,7 @@ scsi_host_alloc_command(struct Scsi_Host *shost, gfp_t gfp_mask)
241241
*/
242242
struct scsi_cmnd *__scsi_get_command(struct Scsi_Host *shost, gfp_t gfp_mask)
243243
{
244-
struct scsi_cmnd *cmd;
245-
unsigned char *buf;
246-
247-
cmd = scsi_host_alloc_command(shost, gfp_mask);
244+
struct scsi_cmnd *cmd = scsi_host_alloc_command(shost, gfp_mask);
248245

249246
if (unlikely(!cmd)) {
250247
unsigned long flags;
@@ -258,9 +255,15 @@ struct scsi_cmnd *__scsi_get_command(struct Scsi_Host *shost, gfp_t gfp_mask)
258255
spin_unlock_irqrestore(&shost->free_list_lock, flags);
259256

260257
if (cmd) {
258+
void *buf, *prot;
259+
261260
buf = cmd->sense_buffer;
261+
prot = cmd->prot_sdb;
262+
262263
memset(cmd, 0, sizeof(*cmd));
264+
263265
cmd->sense_buffer = buf;
266+
cmd->prot_sdb = prot;
264267
}
265268
}
266269

0 commit comments

Comments
 (0)