All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mike Christie <michaelc@cs.wisc.edu>
To: jayamohan.kallickal@emulex.com
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH 4/5] be2iscsi: check before destroy
Date: Wed, 13 Apr 2011 16:45:08 -0500	[thread overview]
Message-ID: <4DA61964.2080903@cs.wisc.edu> (raw)
In-Reply-To: <f790abc7-bcb9-49d2-8a6d-1cb7cd976ce0@exht1.ad.emulex.com>

[-- Attachment #1: Type: text/plain, Size: 1003 bytes --]

On 03/25/2011 04:24 PM, jayamohan.kallickal@emulex.com wrote:
> From: Jayamohan Kallickal<jayamohan.kallickal@emulex.com>
>
>       This patch checks if boot_kset is created before
> 	 attempting to destroy it.
>
> Signed-off-by: Jayamohan Kallickal<jayamohan.kallickal@emulex.com>
> ---
>   drivers/scsi/be2iscsi/be_main.c |    6 ++++--
>   1 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
> index 7fe38a4..91b354d 100644
> --- a/drivers/scsi/be2iscsi/be_main.c
> +++ b/drivers/scsi/be2iscsi/be_main.c
> @@ -420,7 +420,8 @@ static int beiscsi_setup_boot_info(struct beiscsi_hba *phba)
>   	return 0;
>
>   free_kset:
> -	iscsi_boot_destroy_kset(phba->boot_kset);
> +	if (phba->boot_kset)
> +		iscsi_boot_destroy_kset(phba->boot_kset);

This check is not needed, because in this path it is always set.

I fixed this up for you and made it so iscsi_boot_destroy_kset checks 
for null for the caller like how kfree does.


[-- Attachment #2: be2iscsi-fix-rmmod-due-to-mem-issues.patch --]
[-- Type: text/plain, Size: 1588 bytes --]

be2iscsi: Fix boot_kset destruction

This patch has iscsi_boot_destroy_kset check for NULL boot_ksets,
before destroying them. This fixes a bug in be2iscsi's rmmod
path where it was passing in a NULL boot_kset when boot was
not setup.

This also fixes a bug where be2iscsi was accessing memory that
was freed. It was calling iscsi_boot_destroy_kset and
accessing the phba after calling iscsi_host_free which could
free the phba.

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

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index 24e20ba..d01f2fe 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -4144,10 +4144,10 @@ static void beiscsi_remove(struct pci_dev *pcidev)
 			    phba->ctrl.mbox_mem_alloced.size,
 			    phba->ctrl.mbox_mem_alloced.va,
 			    phba->ctrl.mbox_mem_alloced.dma);
+	iscsi_boot_destroy_kset(phba->boot_kset);
 	iscsi_host_remove(phba->shost);
 	pci_dev_put(phba->pcidev);
 	iscsi_host_free(phba->shost);
-	iscsi_boot_destroy_kset(phba->boot_kset);
 }
 
 static void beiscsi_msix_enable(struct beiscsi_hba *phba)
diff --git a/drivers/scsi/iscsi_boot_sysfs.c b/drivers/scsi/iscsi_boot_sysfs.c
index df6bff7..0d8b0cd 100644
--- a/drivers/scsi/iscsi_boot_sysfs.c
+++ b/drivers/scsi/iscsi_boot_sysfs.c
@@ -472,6 +472,9 @@ void iscsi_boot_destroy_kset(struct iscsi_boot_kset *boot_kset)
 {
 	struct iscsi_boot_kobj *boot_kobj, *tmp_kobj;
 
+	if (!boot_kset)
+		return;
+
 	list_for_each_entry_safe(boot_kobj, tmp_kobj,
 				 &boot_kset->kobj_list, list)
 		iscsi_boot_remove_kobj(boot_kobj);

  reply	other threads:[~2011-04-13 21:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1301088242-29477-1-git-send-email-jayamohan.kallickal@emulex.com>
2011-03-25 21:23 ` [PATCH 2/5] be2iscsi: Modifying Maintainer's emailid jayamohan.kallickal
2011-03-25 21:23 ` [PATCH 3/5] be2iscsi: Set a timeout to FW jayamohan.kallickal
2011-03-25 21:24 ` [PATCH 4/5] be2iscsi: check before destroy jayamohan.kallickal
2011-04-13 21:45   ` Mike Christie [this message]
2011-03-25 21:24 ` [PATCH 5/5] be2iscsi: Bug Fix for proper setting of FW jayamohan.kallickal
2011-03-25 21:24 ` be2iscsi: copyright and other changes jayamohan.kallickal
2011-03-26  0:35   ` Mike Christie

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=4DA61964.2080903@cs.wisc.edu \
    --to=michaelc@cs.wisc.edu \
    --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 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.