linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] hpsa: fix memory leak in hpsa_hba_mode_enabled
@ 2014-05-15 20:44 Stephen M. Cameron
  2014-05-15 20:44 ` [PATCH 2/2] hpsa: do not ignore failure of sense controller parameters command Stephen M. Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: Stephen M. Cameron @ 2014-05-15 20:44 UTC (permalink / raw)
  To: james.bottomley
  Cc: justin.lindley, martin.petersen, linux-scsi, stephenmcameron,
	joseph.t.handzik, thenzl, michael.miller, elliott, scott.teel

From: Joe Handzik <joseph.t.handzik@hp.com>

And while we're at it fix a magic number

Signed-off-by: Joe Handzik <joseph.t.handzik@hp.com>
Signed-off-by: Stephen M. Cameron <scameron@beardog.cce.hp.com>
---
 drivers/scsi/hpsa.c |    7 ++++++-
 drivers/scsi/hpsa.h |    1 +
 2 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 2fe8705..a0da81c 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -2967,6 +2967,7 @@ u8 *figure_lunaddrbytes(struct ctlr_info *h, int raid_ctlr_position, int i,
 static int hpsa_hba_mode_enabled(struct ctlr_info *h)
 {
 	int rc;
+	int hba_mode_enabled;
 	struct bmic_controller_parameters *ctlr_params;
 	ctlr_params = kzalloc(sizeof(struct bmic_controller_parameters),
 		GFP_KERNEL);
@@ -2979,7 +2980,11 @@ static int hpsa_hba_mode_enabled(struct ctlr_info *h)
 		kfree(ctlr_params);
 		return 0;
 	}
-	return ctlr_params->nvram_flags & (1 << 3) ? 1 : 0;
+
+	hba_mode_enabled =
+		((ctlr_params->nvram_flags & HBA_MODE_ENABLED_FLAG) != 0);
+	kfree(ctlr_params);
+	return hba_mode_enabled;
 }
 
 static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
index 18f5093..24472ce 100644
--- a/drivers/scsi/hpsa.h
+++ b/drivers/scsi/hpsa.h
@@ -91,6 +91,7 @@ struct bmic_controller_parameters {
 	u8   automatic_drive_slamming;
 	u8   reserved1;
 	u8   nvram_flags;
+#define HBA_MODE_ENABLED_FLAG (1 << 3)
 	u8   cache_nvram_flags;
 	u8   drive_config_flags;
 	u16  reserved2;


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH 2/2] hpsa: do not ignore failure of sense controller parameters command
  2014-05-15 20:44 [PATCH 1/2] hpsa: fix memory leak in hpsa_hba_mode_enabled Stephen M. Cameron
@ 2014-05-15 20:44 ` Stephen M. Cameron
  0 siblings, 0 replies; 2+ messages in thread
From: Stephen M. Cameron @ 2014-05-15 20:44 UTC (permalink / raw)
  To: james.bottomley
  Cc: justin.lindley, martin.petersen, linux-scsi, stephenmcameron,
	joseph.t.handzik, thenzl, michael.miller, elliott, scott.teel

From: Joe Handzik <joseph.t.handzik@hp.com>

Signed-off-by: Joe Handzik <joseph.t.handzik@hp.com>
Signed-off-by: Stephen M. Cameron <scameron@beardog.cce.hp.com>
---
 drivers/scsi/hpsa.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index a0da81c..654e341 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -2973,12 +2973,12 @@ static int hpsa_hba_mode_enabled(struct ctlr_info *h)
 		GFP_KERNEL);
 
 	if (!ctlr_params)
-		return 0;
+		return -ENOMEM;
 	rc = hpsa_bmic_ctrl_mode_sense(h, RAID_CTLR_LUNID, 0, ctlr_params,
 		sizeof(struct bmic_controller_parameters));
-	if (rc != 0) {
+	if (rc) {
 		kfree(ctlr_params);
-		return 0;
+		return rc;
 	}
 
 	hba_mode_enabled =
@@ -3025,6 +3025,8 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
 	memset(lunzerobits, 0, sizeof(lunzerobits));
 
 	rescan_hba_mode = hpsa_hba_mode_enabled(h);
+	if (rescan_hba_mode < 0)
+		goto out;
 
 	if (!h->hba_mode_enabled && rescan_hba_mode)
 		dev_warn(&h->pdev->dev, "HBA mode enabled\n");


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-05-15 20:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-15 20:44 [PATCH 1/2] hpsa: fix memory leak in hpsa_hba_mode_enabled Stephen M. Cameron
2014-05-15 20:44 ` [PATCH 2/2] hpsa: do not ignore failure of sense controller parameters command Stephen M. Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).