Subject: Re: [PATCH] qlge: call ql_core_dump() only if dump memory was allocated.

From: Malahal Naineni <[email-masked]>
Date: Fri, 20 Sep 2013 13:57:35 -0500

Joe Perches [[email-masked]] wrote:
> On Fri, 2013-09-20 at 11:59 -0500, Malahal Naineni wrote:
> > Also changed a log message to indicate that memory was not allocated
> > instead of memory not available!
> []
> > diff --git a/drivers/net/ethernet/qlogic/qlge/qlge_mpi.c b/drivers/net/ethernet/qlogic/qlge/qlge_mpi.c
> []
> > @@ -1274,11 +1274,13 @@ void ql_mpi_reset_work(struct work_struct *work)
> >  		return;
> >  	}
> >  
> > -	if (!ql_core_dump(qdev, qdev->mpi_coredump)) {
> > -		netif_err(qdev, drv, qdev->ndev, "Core is dumped!\n");
> > -		qdev->core_is_dumped = 1;
> > -		queue_delayed_work(qdev->workqueue,
> > -			&qdev->mpi_core_to_log, 5 * HZ);
> > +	if (qdev->mpi_coredump) {
> > +		if (!ql_core_dump(qdev, qdev->mpi_coredump)) {
> > +			netif_err(qdev, drv, qdev->ndev, "Core is dumped!\n");
> > +			qdev->core_is_dumped = 1;
> > +			queue_delayed_work(qdev->workqueue,
> > +				&qdev->mpi_core_to_log, 5 * HZ);
> > +		}
> 
> This can be done without adding another indentation level
> 
> 	if (qdev->mpi_coredump &&
> 	    !ql_core_dump(qdev, qdev->mpi_coredump)) {
> 
> 

Makes sense! Sending another patch as suggested:

>>From b4e1561cb46242c33a77484160f1f1cc3d0e3ffc Mon Sep 17 00:00:00 2001
From: Malahal Naineni <[email-masked]>
Date: Fri, 20 Sep 2013 10:18:19 -0500
Subject: [PATCH] qlge: call ql_core_dump() only if dump memory was allocated.

Also changed a log message to indicate that memory was not allocated
instead of memory not available!

Signed-off-by: Malahal Naineni <[email-masked]>
---
 drivers/net/ethernet/qlogic/qlge/qlge_dbg.c | 4 ++--
 drivers/net/ethernet/qlogic/qlge/qlge_mpi.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qlge/qlge_dbg.c b/drivers/net/ethernet/qlogic/qlge/qlge_dbg.c
index 10093f0..6bc5db7 100644
--- a/drivers/net/ethernet/qlogic/qlge/qlge_dbg.c
+++ b/drivers/net/ethernet/qlogic/qlge/qlge_dbg.c
@@ -740,8 +740,8 @@ int ql_core_dump(struct ql_adapter *qdev, struct ql_mpi_coredump *mpi_coredump)
 	int i;
 
 	if (!mpi_coredump) {
-		netif_err(qdev, drv, qdev->ndev, "No memory available\n");
-		return -ENOMEM;
+		netif_err(qdev, drv, qdev->ndev, "No memory allocated\n");
+		return -EINVAL;
 	}
 
 	/* Try to get the spinlock, but dont worry if
diff --git a/drivers/net/ethernet/qlogic/qlge/qlge_mpi.c b/drivers/net/ethernet/qlogic/qlge/qlge_mpi.c
index ff2bf8a..7ad1460 100644
--- a/drivers/net/ethernet/qlogic/qlge/qlge_mpi.c
+++ b/drivers/net/ethernet/qlogic/qlge/qlge_mpi.c
@@ -1274,7 +1274,7 @@ void ql_mpi_reset_work(struct work_struct *work)
 		return;
 	}
 
-	if (!ql_core_dump(qdev, qdev->mpi_coredump)) {
+	if (qdev->mpi_coredump && !ql_core_dump(qdev, qdev->mpi_coredump)) {
 		netif_err(qdev, drv, qdev->ndev, "Core is dumped!\n");
 		qdev->core_is_dumped = 1;
 		queue_delayed_work(qdev->workqueue,
-- 
1.7.11.7