All of lore.kernel.org
 help / color / mirror / Atom feed
* re: [SCSI] be2iscsi: WRB Initialization and Failure code path change
@ 2013-01-31 19:56 Dan Carpenter
  0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2013-01-31 19:56 UTC (permalink / raw)
  To: jayamohan.kallickal; +Cc: linux-scsi

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2013-01-31 19:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-31 19:56 [SCSI] be2iscsi: WRB Initialization and Failure code path change Dan Carpenter

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.