From: Dan Carpenter <dan.carpenter@oracle.com>
To: jayamohan.kallickal@emulex.com
Cc: linux-scsi@vger.kernel.org
Subject: re: [SCSI] be2iscsi: WRB Initialization and Failure code path change
Date: Thu, 31 Jan 2013 22:56:06 +0300 [thread overview]
Message-ID: <20130131195606.GA4063@elgon.mountain> (raw)
Hello Jayamohan,
I had a question about 3ec7827134a9: "[SCSI] be2iscsi: WRB
Initialization and Failure code path change" from Apr 3, 2012.
drivers/scsi/be2iscsi/be_main.c
2683 for (index = 0; index < phba->params.cxns_per_ctrl * 2; index += 2) {
^^^^^^^^^^
We are allocating every other element in the array. Why?
2684 pwrb_context = &phwi_ctrlr->wrb_context[index];
2685 pwrb_context->pwrb_handle_base =
2686 kzalloc(sizeof(struct wrb_handle *) *
2687 phba->params.wrbs_per_cxn, GFP_KERNEL);
2688 if (!pwrb_context->pwrb_handle_base) {
2689 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
2690 "BM_%d : Mem Alloc Failed. Failing to load\n");
2691 goto init_wrb_hndl_failed;
2692 }
[snip]
2746 init_wrb_hndl_failed:
2747 for (j = index; j > 0; j--) {
^^^^^^^^^^^^^^^^^^^^^
Here we are freeing every element in the array except ->wrb_context[0].
Some of the elements were not allocated, and doesn't skipping zero lead
to a memory leak?
2748 pwrb_context = &phwi_ctrlr->wrb_context[j];
2749 kfree(pwrb_context->pwrb_handle_base);
2750 kfree(pwrb_context->pwrb_handle_basestd);
2751 }
2752 return -ENOMEM;
2753 }
regards,
dan carpenter
reply other threads:[~2013-01-31 19:56 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20130131195606.GA4063@elgon.mountain \
--to=dan.carpenter@oracle.com \
--cc=jayamohan.kallickal@emulex.com \
--cc=linux-scsi@vger.kernel.org \
/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