public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
From: Mike Christie <michaelc@cs.wisc.edu>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Ravi Anand <ravi.anand@qlogic.com>,
	Vikas Chaudhary <vikas.chaudhary@qlogic.com>,
	iscsi-driver@qlogic.com,
	"James E.J. Bottomley" <JBottomley@parallels.com>,
	linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [patch] [SCSI] qla4xxx: don't free pool that wasn't allocated
Date: Thu, 17 May 2012 15:55:41 +0000	[thread overview]
Message-ID: <4FB51F7D.9070105@cs.wisc.edu> (raw)
In-Reply-To: <20120517071120.GG14660@elgon.mountain>

On 05/17/2012 02:11 AM, Dan Carpenter wrote:
> In the original code if dma_pool_alloc() fails then we call
> dma_pool_free().  The problem is that "chap_table" is NULL and
> "chap_dma" is uninitialized so it will cause an error.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> diff --git a/drivers/scsi/qla4xxx/ql4_mbx.c b/drivers/scsi/qla4xxx/ql4_mbx.c
> index 7ac21da..21dce92 100644
> --- a/drivers/scsi/qla4xxx/ql4_mbx.c
> +++ b/drivers/scsi/qla4xxx/ql4_mbx.c
> @@ -1329,10 +1329,8 @@ int qla4xxx_get_chap(struct scsi_qla_host *ha, char *username, char *password,
>  	dma_addr_t chap_dma;
>  
>  	chap_table = dma_pool_alloc(ha->chap_dma_pool, GFP_KERNEL, &chap_dma);
> -	if (chap_table = NULL) {
> -		ret = -ENOMEM;
> -		goto exit_get_chap;
> -	}
> +	if (chap_table = NULL)
> +		return -ENOMEM;
>  
>  	chap_size = sizeof(struct ql4_chap_table);
>  	memset(chap_table, 0, chap_size);

I thought dma_pool_free checked the vaddr/chap_table like how kfree
checks for nulls. You are right. Looks ok to me.

Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>

      parent reply	other threads:[~2012-05-17 15:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-17  7:11 [patch] [SCSI] qla4xxx: don't free pool that wasn't allocated Dan Carpenter
2012-05-17  7:13 ` [patch] [SCSI] qla2xxx: " Dan Carpenter
2012-05-17 17:04   ` Chad Dupuis
2012-05-17 15:55 ` Mike Christie [this message]

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=4FB51F7D.9070105@cs.wisc.edu \
    --to=michaelc@cs.wisc.edu \
    --cc=JBottomley@parallels.com \
    --cc=dan.carpenter@oracle.com \
    --cc=iscsi-driver@qlogic.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=ravi.anand@qlogic.com \
    --cc=vikas.chaudhary@qlogic.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox