Skip to content

Commit

Permalink
[SCSI] Fix protection scsi_data_buffer leak
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Martin K. Petersen authored and James Bottomley committed Oct 2, 2009
1 parent 35e1a5d commit b4c2554
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions drivers/scsi/scsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,7 @@ scsi_host_alloc_command(struct Scsi_Host *shost, gfp_t gfp_mask)
*/
struct scsi_cmnd *__scsi_get_command(struct Scsi_Host *shost, gfp_t gfp_mask)
{
struct scsi_cmnd *cmd;
unsigned char *buf;

cmd = scsi_host_alloc_command(shost, gfp_mask);
struct scsi_cmnd *cmd = scsi_host_alloc_command(shost, gfp_mask);

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

if (cmd) {
void *buf, *prot;

buf = cmd->sense_buffer;
prot = cmd->prot_sdb;

memset(cmd, 0, sizeof(*cmd));

cmd->sense_buffer = buf;
cmd->prot_sdb = prot;
}
}

Expand Down

0 comments on commit b4c2554

Please sign in to comment.