diff options
author | Martin K. Petersen <martin.petersen@oracle.com> | 2009-09-18 17:33:01 -0400 |
---|---|---|
committer | James Bottomley <James.Bottomley@suse.de> | 2009-10-02 10:46:52 -0400 |
commit | b4c2554d40ceac130a8d062eaa8838ed22158c45 (patch) | |
tree | 370f6c78d8186365c6c595e5fcf6d41b3f67137b /drivers/scsi | |
parent | 35e1a5d90b66487d754ef2f2dcbf1007f806d921 (diff) |
[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>
Diffstat (limited to 'drivers/scsi')
-rw-r--r-- | drivers/scsi/scsi.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index b6e03074cb8f..dd098cad337b 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c | |||
@@ -241,10 +241,7 @@ scsi_host_alloc_command(struct Scsi_Host *shost, gfp_t gfp_mask) | |||
241 | */ | 241 | */ |
242 | struct scsi_cmnd *__scsi_get_command(struct Scsi_Host *shost, gfp_t gfp_mask) | 242 | struct scsi_cmnd *__scsi_get_command(struct Scsi_Host *shost, gfp_t gfp_mask) |
243 | { | 243 | { |
244 | struct scsi_cmnd *cmd; | 244 | struct scsi_cmnd *cmd = scsi_host_alloc_command(shost, gfp_mask); |
245 | unsigned char *buf; | ||
246 | |||
247 | cmd = scsi_host_alloc_command(shost, gfp_mask); | ||
248 | 245 | ||
249 | if (unlikely(!cmd)) { | 246 | if (unlikely(!cmd)) { |
250 | unsigned long flags; | 247 | unsigned long flags; |
@@ -258,9 +255,15 @@ struct scsi_cmnd *__scsi_get_command(struct Scsi_Host *shost, gfp_t gfp_mask) | |||
258 | spin_unlock_irqrestore(&shost->free_list_lock, flags); | 255 | spin_unlock_irqrestore(&shost->free_list_lock, flags); |
259 | 256 | ||
260 | if (cmd) { | 257 | if (cmd) { |
258 | void *buf, *prot; | ||
259 | |||
261 | buf = cmd->sense_buffer; | 260 | buf = cmd->sense_buffer; |
261 | prot = cmd->prot_sdb; | ||
262 | |||
262 | memset(cmd, 0, sizeof(*cmd)); | 263 | memset(cmd, 0, sizeof(*cmd)); |
264 | |||
263 | cmd->sense_buffer = buf; | 265 | cmd->sense_buffer = buf; |
266 | cmd->prot_sdb = prot; | ||
264 | } | 267 | } |
265 | } | 268 | } |
266 | 269 | ||