From: Boaz Harrosh <bharrosh@panasas.com>
To: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: James.Bottomley@hansenpartnership.com, linux-scsi@vger.kernel.org
Subject: Re: [PATCH 3/5] scsi: Fix protection scsi_data_buffer leak
Date: Sun, 13 Sep 2009 12:36:10 +0300 [thread overview]
Message-ID: <4AACBD0A.90703@panasas.com> (raw)
In-Reply-To: <1252696852-17091-4-git-send-email-martin.petersen@oracle.com>
On 09/11/2009 10:20 PM, Martin K. Petersen wrote:
> We would leak a scsi_data_buffer if the free_list command was of the
> protected variety.
>
> Reported-by: Boaz Harrosh <bharrosh@panasas.com>
Reviewed-by: Boaz Harrosh <bharrosh@panasas.com>
I like the locality of the temp variables, thanks.
> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
> ---
> 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 2de5f3a..69397bb 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)
> */
> 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;
> @@ -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;
> }
> }
>
next prev parent reply other threads:[~2009-09-13 9:36 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-11 19:20 DIF/DIX updates for 2.6.32 Martin K. Petersen
2009-09-11 19:20 ` [PATCH 1/5] scsi: Deprecate SCSI_PROT_*_CONVERT operations Martin K. Petersen
2009-09-18 23:16 ` James Smart
2009-09-11 19:20 ` [PATCH 2/5] sd: Detach DIF from block integrity infrastructure Martin K. Petersen
2009-09-11 19:20 ` [PATCH 3/5] scsi: Fix protection scsi_data_buffer leak Martin K. Petersen
2009-09-13 9:36 ` Boaz Harrosh [this message]
2009-09-11 19:20 ` [PATCH 4/5] sd: Support disks formatted with DIF Type 2 Martin K. Petersen
2009-09-13 9:37 ` Boaz Harrosh
2009-09-11 19:20 ` [PATCH 5/5] scsi_debug: Implement support for " Martin K. Petersen
2009-09-11 23:06 ` Douglas Gilbert
-- strict thread matches above, loose matches on Subject: below --
2009-09-18 21:32 Final DIF/DIX patches for 2.6.32 Martin K. Petersen
2009-09-18 21:33 ` [PATCH 3/5] scsi: Fix protection scsi_data_buffer leak Martin K. Petersen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4AACBD0A.90703@panasas.com \
--to=bharrosh@panasas.com \
--cc=James.Bottomley@hansenpartnership.com \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.