LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [2.6 patch] hwmon/ibmpex.c: fix NULL dereference
@ 2007-10-17 19:29 Adrian Bunk
  2007-10-17 19:39 ` Nish Aravamudan
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Adrian Bunk @ 2007-10-17 19:29 UTC (permalink / raw)
  To: Darrick J. Wong, Mark M. Hoffman; +Cc: lm-sensors, linux-kernel

Don't dereference "data" when we know for sure it's NULL.

Spotted by the Coverity checker.

Signed-off-by: Adrian Bunk <bunk@kernel.org>

---
66bec2ef5c6d55fc30ef6ac5bb97fdfcfaf394f2 
diff --git a/drivers/hwmon/ibmpex.c b/drivers/hwmon/ibmpex.c
index c462824..e14ce3d 100644
--- a/drivers/hwmon/ibmpex.c
+++ b/drivers/hwmon/ibmpex.c
@@ -457,7 +457,7 @@ static void ibmpex_register_bmc(int iface, struct device *dev)
 	data = kzalloc(sizeof(*data), GFP_KERNEL);
 	if (!data) {
 		printk(KERN_ERR DRVNAME ": Insufficient memory for BMC "
-		       "interface %d.\n", data->interface);
+		       "interface.\n");
 		return;
 	}
 


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

* Re: [2.6 patch] hwmon/ibmpex.c: fix NULL dereference
  2007-10-17 19:29 [2.6 patch] hwmon/ibmpex.c: fix NULL dereference Adrian Bunk
@ 2007-10-17 19:39 ` Nish Aravamudan
  2007-10-17 19:50   ` Adrian Bunk
  2007-10-17 20:58 ` [lm-sensors] " Jean Delvare
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 11+ messages in thread
From: Nish Aravamudan @ 2007-10-17 19:39 UTC (permalink / raw)
  To: Adrian Bunk; +Cc: Darrick J. Wong, Mark M. Hoffman, lm-sensors, linux-kernel

On 10/17/07, Adrian Bunk <bunk@kernel.org> wrote:
> Don't dereference "data" when we know for sure it's NULL.
>
> Spotted by the Coverity checker.
>
> Signed-off-by: Adrian Bunk <bunk@kernel.org>
>
> ---
> 66bec2ef5c6d55fc30ef6ac5bb97fdfcfaf394f2
> diff --git a/drivers/hwmon/ibmpex.c b/drivers/hwmon/ibmpex.c
> index c462824..e14ce3d 100644
> --- a/drivers/hwmon/ibmpex.c
> +++ b/drivers/hwmon/ibmpex.c
> @@ -457,7 +457,7 @@ static void ibmpex_register_bmc(int iface, struct device *dev)
>         data = kzalloc(sizeof(*data), GFP_KERNEL);
>         if (!data) {
>                 printk(KERN_ERR DRVNAME ": Insufficient memory for BMC "
> -                      "interface %d.\n", data->interface);
> +                      "interface.\n");

Hrm but what data->interface would be is specified by the iface
parameter? Just spit that out instead?

Thanks,
Nish

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

* Re: [2.6 patch] hwmon/ibmpex.c: fix NULL dereference
  2007-10-17 19:39 ` Nish Aravamudan
@ 2007-10-17 19:50   ` Adrian Bunk
  0 siblings, 0 replies; 11+ messages in thread
From: Adrian Bunk @ 2007-10-17 19:50 UTC (permalink / raw)
  To: Nish Aravamudan
  Cc: Darrick J. Wong, Mark M. Hoffman, lm-sensors, linux-kernel

On Wed, Oct 17, 2007 at 12:39:59PM -0700, Nish Aravamudan wrote:
> On 10/17/07, Adrian Bunk <bunk@kernel.org> wrote:
> > Don't dereference "data" when we know for sure it's NULL.
> >
> > Spotted by the Coverity checker.
> >
> > Signed-off-by: Adrian Bunk <bunk@kernel.org>
> >
> > ---
> > 66bec2ef5c6d55fc30ef6ac5bb97fdfcfaf394f2
> > diff --git a/drivers/hwmon/ibmpex.c b/drivers/hwmon/ibmpex.c
> > index c462824..e14ce3d 100644
> > --- a/drivers/hwmon/ibmpex.c
> > +++ b/drivers/hwmon/ibmpex.c
> > @@ -457,7 +457,7 @@ static void ibmpex_register_bmc(int iface, struct device *dev)
> >         data = kzalloc(sizeof(*data), GFP_KERNEL);
> >         if (!data) {
> >                 printk(KERN_ERR DRVNAME ": Insufficient memory for BMC "
> > -                      "interface %d.\n", data->interface);
> > +                      "interface.\n");
> 
> Hrm but what data->interface would be is specified by the iface
> parameter? Just spit that out instead?

This is only a symptom of the problem that kzalloc() failed, and when 
you are getting into such a situation here you have bigger problems - 
and these are not related to this driver.

Feel free to send a different patch, but IMHO "Insufficient memory" 
alone is enough information in this case.

> Thanks,
> Nish

cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed


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

* Re: [lm-sensors] [2.6 patch] hwmon/ibmpex.c: fix NULL dereference
  2007-10-17 19:29 [2.6 patch] hwmon/ibmpex.c: fix NULL dereference Adrian Bunk
  2007-10-17 19:39 ` Nish Aravamudan
@ 2007-10-17 20:58 ` Jean Delvare
  2007-10-17 22:15   ` [PATCH] ibmpex: Change printk to dev_{info,err} macros Darrick J. Wong
  2007-10-17 21:10 ` [2.6 patch] hwmon/ibmpex.c: fix NULL dereference Darrick J. Wong
  2007-10-18 13:34 ` Mark M. Hoffman
  3 siblings, 1 reply; 11+ messages in thread
From: Jean Delvare @ 2007-10-17 20:58 UTC (permalink / raw)
  To: Adrian Bunk; +Cc: Darrick J. Wong, Mark M. Hoffman, linux-kernel, lm-sensors

On Wed, 17 Oct 2007 21:29:02 +0200, Adrian Bunk wrote:
> Don't dereference "data" when we know for sure it's NULL.
> 
> Spotted by the Coverity checker.
> 
> Signed-off-by: Adrian Bunk <bunk@kernel.org>
> 
> ---
> 66bec2ef5c6d55fc30ef6ac5bb97fdfcfaf394f2 
> diff --git a/drivers/hwmon/ibmpex.c b/drivers/hwmon/ibmpex.c
> index c462824..e14ce3d 100644
> --- a/drivers/hwmon/ibmpex.c
> +++ b/drivers/hwmon/ibmpex.c
> @@ -457,7 +457,7 @@ static void ibmpex_register_bmc(int iface, struct device *dev)
>  	data = kzalloc(sizeof(*data), GFP_KERNEL);
>  	if (!data) {
>  		printk(KERN_ERR DRVNAME ": Insufficient memory for BMC "
> -		       "interface %d.\n", data->interface);
> +		       "interface.\n");
>  		return;
>  	}

As a side note, dev_err() should be used instead of printk here, and
possibly in other places. Darrick, could you please send a patch fixing
this?

Thanks,
-- 
Jean Delvare

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

* Re: [2.6 patch] hwmon/ibmpex.c: fix NULL dereference
  2007-10-17 19:29 [2.6 patch] hwmon/ibmpex.c: fix NULL dereference Adrian Bunk
  2007-10-17 19:39 ` Nish Aravamudan
  2007-10-17 20:58 ` [lm-sensors] " Jean Delvare
@ 2007-10-17 21:10 ` Darrick J. Wong
  2007-10-18 13:34 ` Mark M. Hoffman
  3 siblings, 0 replies; 11+ messages in thread
From: Darrick J. Wong @ 2007-10-17 21:10 UTC (permalink / raw)
  To: Adrian Bunk; +Cc: Mark M. Hoffman, lm-sensors, linux-kernel

On Wed, Oct 17, 2007 at 09:29:02PM +0200, Adrian Bunk wrote:
> Don't dereference "data" when we know for sure it's NULL.
> 
> Spotted by the Coverity checker.
> 
> Signed-off-by: Adrian Bunk <bunk@kernel.org>
> 
> ---
> 66bec2ef5c6d55fc30ef6ac5bb97fdfcfaf394f2 
> diff --git a/drivers/hwmon/ibmpex.c b/drivers/hwmon/ibmpex.c
> index c462824..e14ce3d 100644
> --- a/drivers/hwmon/ibmpex.c
> +++ b/drivers/hwmon/ibmpex.c
> @@ -457,7 +457,7 @@ static void ibmpex_register_bmc(int iface, struct device *dev)
>  	data = kzalloc(sizeof(*data), GFP_KERNEL);
>  	if (!data) {
>  		printk(KERN_ERR DRVNAME ": Insufficient memory for BMC "
> -		       "interface %d.\n", data->interface);
> +		       "interface.\n");
>  		return;
>  	}
> 
> 
ACK.

--D

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

* [PATCH] ibmpex: Change printk to dev_{info,err} macros
  2007-10-17 20:58 ` [lm-sensors] " Jean Delvare
@ 2007-10-17 22:15   ` Darrick J. Wong
  2007-10-19  8:54     ` Jean Delvare
  0 siblings, 1 reply; 11+ messages in thread
From: Darrick J. Wong @ 2007-10-17 22:15 UTC (permalink / raw)
  To: Jean Delvare; +Cc: Adrian Bunk, Mark M. Hoffman, linux-kernel, lm-sensors

Clean up printk use in ibmpex to use dev_err/dev_info macros and reword
some of the messages to be a bit more clear.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
---

 drivers/hwmon/ibmpex.c |   48 +++++++++++++++++++++++-------------------------
 1 files changed, 23 insertions(+), 25 deletions(-)

diff --git a/drivers/hwmon/ibmpex.c b/drivers/hwmon/ibmpex.c
index c462824..3c8278b 100644
--- a/drivers/hwmon/ibmpex.c
+++ b/drivers/hwmon/ibmpex.c
@@ -140,10 +140,10 @@ static int ibmpex_send_message(struct ibmpex_bmc_data *data)
 
 	return 0;
 out1:
-	printk(KERN_ERR "%s: request_settime=%x\n", __FUNCTION__, err);
+	dev_err(data->bmc_device, "request_settime=%x\n", err);
 	return err;
 out:
-	printk(KERN_ERR "%s: validate_addr=%x\n", __FUNCTION__, err);
+	dev_err(data->bmc_device, "validate_addr=%x\n", err);
 	return err;
 }
 
@@ -161,14 +161,14 @@ static int ibmpex_ver_check(struct ibmpex_bmc_data *data)
 	data->sensor_major = data->rx_msg_data[0];
 	data->sensor_minor = data->rx_msg_data[1];
 
-	printk(KERN_INFO DRVNAME ": Found BMC with sensor interface "
-	       "v%d.%d %d-%02d-%02d on interface %d\n",
-	       data->sensor_major,
-	       data->sensor_minor,
-	       extract_value(data->rx_msg_data, 2),
-	       data->rx_msg_data[4],
-	       data->rx_msg_data[5],
-	       data->interface);
+	dev_info(data->bmc_device, "Found BMC with sensor interface "
+		 "v%d.%d %d-%02d-%02d on interface %d\n",
+		 data->sensor_major,
+		 data->sensor_minor,
+		 extract_value(data->rx_msg_data, 2),
+		 data->rx_msg_data[4],
+		 data->rx_msg_data[5],
+		 data->interface);
 
 	return 0;
 }
@@ -212,8 +212,8 @@ static int ibmpex_query_sensor_data(struct ibmpex_bmc_data *data, int sensor)
 	wait_for_completion(&data->read_complete);
 
 	if (data->rx_result || data->rx_msg_len < 26) {
-		printk(KERN_ERR "Error reading sensor %d, please check.\n",
-		       sensor);
+		dev_err(data->bmc_device, "Error reading sensor %d.\n",
+			sensor);
 		return -ENOENT;
 	}
 
@@ -456,8 +456,7 @@ static void ibmpex_register_bmc(int iface, struct device *dev)
 
 	data = kzalloc(sizeof(*data), GFP_KERNEL);
 	if (!data) {
-		printk(KERN_ERR DRVNAME ": Insufficient memory for BMC "
-		       "interface %d.\n", data->interface);
+		dev_err(dev, "Insufficient memory for BMC interface.\n");
 		return;
 	}
 
@@ -471,9 +470,8 @@ static void ibmpex_register_bmc(int iface, struct device *dev)
 	err = ipmi_create_user(data->interface, &driver_data.ipmi_hndlrs,
 			       data, &data->user);
 	if (err < 0) {
-		printk(KERN_ERR DRVNAME ": Error, unable to register user with "
-		       "ipmi interface %d\n",
-		       data->interface);
+		dev_err(dev, "Unable to register user with IPMI "
+			"interface %d\n", data->interface);
 		goto out;
 	}
 
@@ -495,9 +493,9 @@ static void ibmpex_register_bmc(int iface, struct device *dev)
 	data->hwmon_dev = hwmon_device_register(data->bmc_device);
 
 	if (IS_ERR(data->hwmon_dev)) {
-		printk(KERN_ERR DRVNAME ": Error, unable to register hwmon "
-		       "class device for interface %d\n",
-		       data->interface);
+		dev_err(data->bmc_device, "Unable to register hwmon "
+			"device for IPMI interface %d\n",
+			data->interface);
 		goto out_user;
 	}
 
@@ -508,7 +506,7 @@ static void ibmpex_register_bmc(int iface, struct device *dev)
 	/* Now go find all the sensors */
 	err = ibmpex_find_sensors(data);
 	if (err) {
-		printk(KERN_ERR "Error %d allocating memory\n", err);
+		dev_err(data->bmc_device, "Error %d allocating memory\n", err);
 		goto out_register;
 	}
 
@@ -561,10 +559,10 @@ static void ibmpex_msg_handler(struct ipmi_recv_msg *msg, void *user_msg_data)
 	struct ibmpex_bmc_data *data = (struct ibmpex_bmc_data *)user_msg_data;
 
 	if (msg->msgid != data->tx_msgid) {
-		printk(KERN_ERR "Received msgid (%02x) and transmitted "
-		       "msgid (%02x) mismatch!\n",
-		       (int)msg->msgid,
-		       (int)data->tx_msgid);
+		dev_err(data->bmc_device, "Mismatch between received msgid "
+			"(%02x) and transmitted msgid (%02x)!\n",
+			(int)msg->msgid,
+			(int)data->tx_msgid);
 		ipmi_free_recv_msg(msg);
 		return;
 	}

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

* Re: [2.6 patch] hwmon/ibmpex.c: fix NULL dereference
  2007-10-17 19:29 [2.6 patch] hwmon/ibmpex.c: fix NULL dereference Adrian Bunk
                   ` (2 preceding siblings ...)
  2007-10-17 21:10 ` [2.6 patch] hwmon/ibmpex.c: fix NULL dereference Darrick J. Wong
@ 2007-10-18 13:34 ` Mark M. Hoffman
  3 siblings, 0 replies; 11+ messages in thread
From: Mark M. Hoffman @ 2007-10-18 13:34 UTC (permalink / raw)
  To: Adrian Bunk; +Cc: Darrick J. Wong, lm-sensors, linux-kernel

Hi:

* Adrian Bunk <bunk@kernel.org> [2007-10-17 21:29:02 +0200]:
> Don't dereference "data" when we know for sure it's NULL.
> 
> Spotted by the Coverity checker.
> 
> Signed-off-by: Adrian Bunk <bunk@kernel.org>
> 
> ---
> 66bec2ef5c6d55fc30ef6ac5bb97fdfcfaf394f2 
> diff --git a/drivers/hwmon/ibmpex.c b/drivers/hwmon/ibmpex.c
> index c462824..e14ce3d 100644
> --- a/drivers/hwmon/ibmpex.c
> +++ b/drivers/hwmon/ibmpex.c
> @@ -457,7 +457,7 @@ static void ibmpex_register_bmc(int iface, struct device *dev)
>  	data = kzalloc(sizeof(*data), GFP_KERNEL);
>  	if (!data) {
>  		printk(KERN_ERR DRVNAME ": Insufficient memory for BMC "
> -		       "interface %d.\n", data->interface);
> +		       "interface.\n");
>  		return;
>  	}
>  

Applied to hwmon-2.6.git/testing, thanks.

-- 
Mark M. Hoffman
mhoffman@lightlink.com


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

* Re: [PATCH] ibmpex: Change printk to dev_{info,err} macros
  2007-10-17 22:15   ` [PATCH] ibmpex: Change printk to dev_{info,err} macros Darrick J. Wong
@ 2007-10-19  8:54     ` Jean Delvare
  2007-10-19 23:35       ` [PATCH v2] " Darrick J. Wong
  0 siblings, 1 reply; 11+ messages in thread
From: Jean Delvare @ 2007-10-19  8:54 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: Adrian Bunk, Mark M. Hoffman, linux-kernel, lm-sensors

Hi Darrick,

On Wed, 17 Oct 2007 15:15:03 -0700, Darrick J. Wong wrote:
> Clean up printk use in ibmpex to use dev_err/dev_info macros and reword
> some of the messages to be a bit more clear.
> 
> Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
> ---
> 
>  drivers/hwmon/ibmpex.c |   48 +++++++++++++++++++++++-------------------------
>  1 files changed, 23 insertions(+), 25 deletions(-)
> 
> diff --git a/drivers/hwmon/ibmpex.c b/drivers/hwmon/ibmpex.c
> index c462824..3c8278b 100644
> --- a/drivers/hwmon/ibmpex.c
> +++ b/drivers/hwmon/ibmpex.c
> @@ -140,10 +140,10 @@ static int ibmpex_send_message(struct ibmpex_bmc_data *data)
>  
>  	return 0;
>  out1:
> -	printk(KERN_ERR "%s: request_settime=%x\n", __FUNCTION__, err);
> +	dev_err(data->bmc_device, "request_settime=%x\n", err);
>  	return err;
>  out:
> -	printk(KERN_ERR "%s: validate_addr=%x\n", __FUNCTION__, err);
> +	dev_err(data->bmc_device, "validate_addr=%x\n", err);
>  	return err;
>  }
>  
> @@ -161,14 +161,14 @@ static int ibmpex_ver_check(struct ibmpex_bmc_data *data)
>  	data->sensor_major = data->rx_msg_data[0];
>  	data->sensor_minor = data->rx_msg_data[1];
>  
> -	printk(KERN_INFO DRVNAME ": Found BMC with sensor interface "
> -	       "v%d.%d %d-%02d-%02d on interface %d\n",
> -	       data->sensor_major,
> -	       data->sensor_minor,
> -	       extract_value(data->rx_msg_data, 2),
> -	       data->rx_msg_data[4],
> -	       data->rx_msg_data[5],
> -	       data->interface);
> +	dev_info(data->bmc_device, "Found BMC with sensor interface "
> +		 "v%d.%d %d-%02d-%02d on interface %d\n",
> +		 data->sensor_major,
> +		 data->sensor_minor,
> +		 extract_value(data->rx_msg_data, 2),
> +		 data->rx_msg_data[4],
> +		 data->rx_msg_data[5],
> +		 data->interface);
>  
>  	return 0;
>  }
> @@ -212,8 +212,8 @@ static int ibmpex_query_sensor_data(struct ibmpex_bmc_data *data, int sensor)
>  	wait_for_completion(&data->read_complete);
>  
>  	if (data->rx_result || data->rx_msg_len < 26) {
> -		printk(KERN_ERR "Error reading sensor %d, please check.\n",
> -		       sensor);
> +		dev_err(data->bmc_device, "Error reading sensor %d.\n",
> +			sensor);
>  		return -ENOENT;
>  	}
>  
> @@ -456,8 +456,7 @@ static void ibmpex_register_bmc(int iface, struct device *dev)
>  
>  	data = kzalloc(sizeof(*data), GFP_KERNEL);
>  	if (!data) {
> -		printk(KERN_ERR DRVNAME ": Insufficient memory for BMC "
> -		       "interface %d.\n", data->interface);
> +		dev_err(dev, "Insufficient memory for BMC interface.\n");
>  		return;
>  	}
>  
> @@ -471,9 +470,8 @@ static void ibmpex_register_bmc(int iface, struct device *dev)
>  	err = ipmi_create_user(data->interface, &driver_data.ipmi_hndlrs,
>  			       data, &data->user);
>  	if (err < 0) {
> -		printk(KERN_ERR DRVNAME ": Error, unable to register user with "
> -		       "ipmi interface %d\n",
> -		       data->interface);
> +		dev_err(dev, "Unable to register user with IPMI "
> +			"interface %d\n", data->interface);
>  		goto out;
>  	}
>  
> @@ -495,9 +493,9 @@ static void ibmpex_register_bmc(int iface, struct device *dev)
>  	data->hwmon_dev = hwmon_device_register(data->bmc_device);
>  
>  	if (IS_ERR(data->hwmon_dev)) {
> -		printk(KERN_ERR DRVNAME ": Error, unable to register hwmon "
> -		       "class device for interface %d\n",
> -		       data->interface);
> +		dev_err(data->bmc_device, "Unable to register hwmon "
> +			"device for IPMI interface %d\n",
> +			data->interface);
>  		goto out_user;
>  	}
>  
> @@ -508,7 +506,7 @@ static void ibmpex_register_bmc(int iface, struct device *dev)
>  	/* Now go find all the sensors */
>  	err = ibmpex_find_sensors(data);
>  	if (err) {
> -		printk(KERN_ERR "Error %d allocating memory\n", err);
> +		dev_err(data->bmc_device, "Error %d allocating memory\n", err);

This message might be misleading, as there are other reasons why
ibmpex_find_sensors() can fail.

>  		goto out_register;
>  	}
>  
> @@ -561,10 +559,10 @@ static void ibmpex_msg_handler(struct ipmi_recv_msg *msg, void *user_msg_data)
>  	struct ibmpex_bmc_data *data = (struct ibmpex_bmc_data *)user_msg_data;
>  
>  	if (msg->msgid != data->tx_msgid) {
> -		printk(KERN_ERR "Received msgid (%02x) and transmitted "
> -		       "msgid (%02x) mismatch!\n",
> -		       (int)msg->msgid,
> -		       (int)data->tx_msgid);
> +		dev_err(data->bmc_device, "Mismatch between received msgid "
> +			"(%02x) and transmitted msgid (%02x)!\n",
> +			(int)msg->msgid,
> +			(int)data->tx_msgid);
>  		ipmi_free_recv_msg(msg);
>  		return;
>  	}

Other than that, the patch looks OK:

Acked-by: Jean Delvare <khali@linux-fr.org>

-- 
Jean Delvare

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

* [PATCH v2] ibmpex: Change printk to dev_{info,err} macros
  2007-10-19  8:54     ` Jean Delvare
@ 2007-10-19 23:35       ` Darrick J. Wong
  2007-10-20 21:30         ` Jean Delvare
  0 siblings, 1 reply; 11+ messages in thread
From: Darrick J. Wong @ 2007-10-19 23:35 UTC (permalink / raw)
  To: Jean Delvare; +Cc: Adrian Bunk, Mark M. Hoffman, linux-kernel, lm-sensors

Ok, I'll change the message to be a bit more accurate.
---
Clean up printk use in ibmpex.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
---

 drivers/hwmon/ibmpex.c |   48 +++++++++++++++++++++++-------------------------
 1 files changed, 23 insertions(+), 25 deletions(-)

diff --git a/drivers/hwmon/ibmpex.c b/drivers/hwmon/ibmpex.c
index c462824..9c9cdb0 100644
--- a/drivers/hwmon/ibmpex.c
+++ b/drivers/hwmon/ibmpex.c
@@ -140,10 +140,10 @@ static int ibmpex_send_message(struct ibmpex_bmc_data *data)
 
 	return 0;
 out1:
-	printk(KERN_ERR "%s: request_settime=%x\n", __FUNCTION__, err);
+	dev_err(data->bmc_device, "request_settime=%x\n", err);
 	return err;
 out:
-	printk(KERN_ERR "%s: validate_addr=%x\n", __FUNCTION__, err);
+	dev_err(data->bmc_device, "validate_addr=%x\n", err);
 	return err;
 }
 
@@ -161,14 +161,14 @@ static int ibmpex_ver_check(struct ibmpex_bmc_data *data)
 	data->sensor_major = data->rx_msg_data[0];
 	data->sensor_minor = data->rx_msg_data[1];
 
-	printk(KERN_INFO DRVNAME ": Found BMC with sensor interface "
-	       "v%d.%d %d-%02d-%02d on interface %d\n",
-	       data->sensor_major,
-	       data->sensor_minor,
-	       extract_value(data->rx_msg_data, 2),
-	       data->rx_msg_data[4],
-	       data->rx_msg_data[5],
-	       data->interface);
+	dev_info(data->bmc_device, "Found BMC with sensor interface "
+		 "v%d.%d %d-%02d-%02d on interface %d\n",
+		 data->sensor_major,
+		 data->sensor_minor,
+		 extract_value(data->rx_msg_data, 2),
+		 data->rx_msg_data[4],
+		 data->rx_msg_data[5],
+		 data->interface);
 
 	return 0;
 }
@@ -212,8 +212,8 @@ static int ibmpex_query_sensor_data(struct ibmpex_bmc_data *data, int sensor)
 	wait_for_completion(&data->read_complete);
 
 	if (data->rx_result || data->rx_msg_len < 26) {
-		printk(KERN_ERR "Error reading sensor %d, please check.\n",
-		       sensor);
+		dev_err(data->bmc_device, "Error reading sensor %d.\n",
+			sensor);
 		return -ENOENT;
 	}
 
@@ -456,8 +456,7 @@ static void ibmpex_register_bmc(int iface, struct device *dev)
 
 	data = kzalloc(sizeof(*data), GFP_KERNEL);
 	if (!data) {
-		printk(KERN_ERR DRVNAME ": Insufficient memory for BMC "
-		       "interface %d.\n", data->interface);
+		dev_err(dev, "Insufficient memory for BMC interface.\n");
 		return;
 	}
 
@@ -471,9 +470,8 @@ static void ibmpex_register_bmc(int iface, struct device *dev)
 	err = ipmi_create_user(data->interface, &driver_data.ipmi_hndlrs,
 			       data, &data->user);
 	if (err < 0) {
-		printk(KERN_ERR DRVNAME ": Error, unable to register user with "
-		       "ipmi interface %d\n",
-		       data->interface);
+		dev_err(dev, "Unable to register user with IPMI "
+			"interface %d\n", data->interface);
 		goto out;
 	}
 
@@ -495,9 +493,9 @@ static void ibmpex_register_bmc(int iface, struct device *dev)
 	data->hwmon_dev = hwmon_device_register(data->bmc_device);
 
 	if (IS_ERR(data->hwmon_dev)) {
-		printk(KERN_ERR DRVNAME ": Error, unable to register hwmon "
-		       "class device for interface %d\n",
-		       data->interface);
+		dev_err(data->bmc_device, "Unable to register hwmon "
+			"device for IPMI interface %d\n",
+			data->interface);
 		goto out_user;
 	}
 
@@ -508,7 +506,7 @@ static void ibmpex_register_bmc(int iface, struct device *dev)
 	/* Now go find all the sensors */
 	err = ibmpex_find_sensors(data);
 	if (err) {
-		printk(KERN_ERR "Error %d allocating memory\n", err);
+		dev_err(data->bmc_device, "Error %d finding sensors\n", err);
 		goto out_register;
 	}
 
@@ -561,10 +559,10 @@ static void ibmpex_msg_handler(struct ipmi_recv_msg *msg, void *user_msg_data)
 	struct ibmpex_bmc_data *data = (struct ibmpex_bmc_data *)user_msg_data;
 
 	if (msg->msgid != data->tx_msgid) {
-		printk(KERN_ERR "Received msgid (%02x) and transmitted "
-		       "msgid (%02x) mismatch!\n",
-		       (int)msg->msgid,
-		       (int)data->tx_msgid);
+		dev_err(data->bmc_device, "Mismatch between received msgid "
+			"(%02x) and transmitted msgid (%02x)!\n",
+			(int)msg->msgid,
+			(int)data->tx_msgid);
 		ipmi_free_recv_msg(msg);
 		return;
 	}

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

* Re: [PATCH v2] ibmpex: Change printk to dev_{info,err} macros
  2007-10-19 23:35       ` [PATCH v2] " Darrick J. Wong
@ 2007-10-20 21:30         ` Jean Delvare
  2007-10-23 11:23           ` Mark M. Hoffman
  0 siblings, 1 reply; 11+ messages in thread
From: Jean Delvare @ 2007-10-20 21:30 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: Adrian Bunk, Mark M. Hoffman, linux-kernel, lm-sensors

On Fri, 19 Oct 2007 16:35:07 -0700, Darrick J. Wong wrote:
> Ok, I'll change the message to be a bit more accurate.
> ---
> Clean up printk use in ibmpex.
> 
> Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
> ---

Acked-by: Jean Delvare <khali@linux-fr.org>

> 
>  drivers/hwmon/ibmpex.c |   48 +++++++++++++++++++++++-------------------------
>  1 files changed, 23 insertions(+), 25 deletions(-)
> 
> diff --git a/drivers/hwmon/ibmpex.c b/drivers/hwmon/ibmpex.c
> index c462824..9c9cdb0 100644
> --- a/drivers/hwmon/ibmpex.c
> +++ b/drivers/hwmon/ibmpex.c
> @@ -140,10 +140,10 @@ static int ibmpex_send_message(struct ibmpex_bmc_data *data)
>  
>  	return 0;
>  out1:
> -	printk(KERN_ERR "%s: request_settime=%x\n", __FUNCTION__, err);
> +	dev_err(data->bmc_device, "request_settime=%x\n", err);
>  	return err;
>  out:
> -	printk(KERN_ERR "%s: validate_addr=%x\n", __FUNCTION__, err);
> +	dev_err(data->bmc_device, "validate_addr=%x\n", err);
>  	return err;
>  }
>  
> @@ -161,14 +161,14 @@ static int ibmpex_ver_check(struct ibmpex_bmc_data *data)
>  	data->sensor_major = data->rx_msg_data[0];
>  	data->sensor_minor = data->rx_msg_data[1];
>  
> -	printk(KERN_INFO DRVNAME ": Found BMC with sensor interface "
> -	       "v%d.%d %d-%02d-%02d on interface %d\n",
> -	       data->sensor_major,
> -	       data->sensor_minor,
> -	       extract_value(data->rx_msg_data, 2),
> -	       data->rx_msg_data[4],
> -	       data->rx_msg_data[5],
> -	       data->interface);
> +	dev_info(data->bmc_device, "Found BMC with sensor interface "
> +		 "v%d.%d %d-%02d-%02d on interface %d\n",
> +		 data->sensor_major,
> +		 data->sensor_minor,
> +		 extract_value(data->rx_msg_data, 2),
> +		 data->rx_msg_data[4],
> +		 data->rx_msg_data[5],
> +		 data->interface);
>  
>  	return 0;
>  }
> @@ -212,8 +212,8 @@ static int ibmpex_query_sensor_data(struct ibmpex_bmc_data *data, int sensor)
>  	wait_for_completion(&data->read_complete);
>  
>  	if (data->rx_result || data->rx_msg_len < 26) {
> -		printk(KERN_ERR "Error reading sensor %d, please check.\n",
> -		       sensor);
> +		dev_err(data->bmc_device, "Error reading sensor %d.\n",
> +			sensor);
>  		return -ENOENT;
>  	}
>  
> @@ -456,8 +456,7 @@ static void ibmpex_register_bmc(int iface, struct device *dev)
>  
>  	data = kzalloc(sizeof(*data), GFP_KERNEL);
>  	if (!data) {
> -		printk(KERN_ERR DRVNAME ": Insufficient memory for BMC "
> -		       "interface %d.\n", data->interface);
> +		dev_err(dev, "Insufficient memory for BMC interface.\n");
>  		return;
>  	}
>  
> @@ -471,9 +470,8 @@ static void ibmpex_register_bmc(int iface, struct device *dev)
>  	err = ipmi_create_user(data->interface, &driver_data.ipmi_hndlrs,
>  			       data, &data->user);
>  	if (err < 0) {
> -		printk(KERN_ERR DRVNAME ": Error, unable to register user with "
> -		       "ipmi interface %d\n",
> -		       data->interface);
> +		dev_err(dev, "Unable to register user with IPMI "
> +			"interface %d\n", data->interface);
>  		goto out;
>  	}
>  
> @@ -495,9 +493,9 @@ static void ibmpex_register_bmc(int iface, struct device *dev)
>  	data->hwmon_dev = hwmon_device_register(data->bmc_device);
>  
>  	if (IS_ERR(data->hwmon_dev)) {
> -		printk(KERN_ERR DRVNAME ": Error, unable to register hwmon "
> -		       "class device for interface %d\n",
> -		       data->interface);
> +		dev_err(data->bmc_device, "Unable to register hwmon "
> +			"device for IPMI interface %d\n",
> +			data->interface);
>  		goto out_user;
>  	}
>  
> @@ -508,7 +506,7 @@ static void ibmpex_register_bmc(int iface, struct device *dev)
>  	/* Now go find all the sensors */
>  	err = ibmpex_find_sensors(data);
>  	if (err) {
> -		printk(KERN_ERR "Error %d allocating memory\n", err);
> +		dev_err(data->bmc_device, "Error %d finding sensors\n", err);
>  		goto out_register;
>  	}
>  
> @@ -561,10 +559,10 @@ static void ibmpex_msg_handler(struct ipmi_recv_msg *msg, void *user_msg_data)
>  	struct ibmpex_bmc_data *data = (struct ibmpex_bmc_data *)user_msg_data;
>  
>  	if (msg->msgid != data->tx_msgid) {
> -		printk(KERN_ERR "Received msgid (%02x) and transmitted "
> -		       "msgid (%02x) mismatch!\n",
> -		       (int)msg->msgid,
> -		       (int)data->tx_msgid);
> +		dev_err(data->bmc_device, "Mismatch between received msgid "
> +			"(%02x) and transmitted msgid (%02x)!\n",
> +			(int)msg->msgid,
> +			(int)data->tx_msgid);
>  		ipmi_free_recv_msg(msg);
>  		return;
>  	}
> 
> !DSPAM:47193f59493201721698080!
> 


-- 
Jean Delvare

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

* Re: [PATCH v2] ibmpex: Change printk to dev_{info,err} macros
  2007-10-20 21:30         ` Jean Delvare
@ 2007-10-23 11:23           ` Mark M. Hoffman
  0 siblings, 0 replies; 11+ messages in thread
From: Mark M. Hoffman @ 2007-10-23 11:23 UTC (permalink / raw)
  To: Jean Delvare; +Cc: Darrick J. Wong, Adrian Bunk, linux-kernel, lm-sensors

Hi:

* Jean Delvare <khali@linux-fr.org> [2007-10-20 23:30:52 +0200]:
> On Fri, 19 Oct 2007 16:35:07 -0700, Darrick J. Wong wrote:
> > Ok, I'll change the message to be a bit more accurate.
> > ---
> > Clean up printk use in ibmpex.
> > 
> > Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
> > ---
> 
> Acked-by: Jean Delvare <khali@linux-fr.org>

Applied to hwmon-2.6.git/testing, thanks.

-- 
Mark M. Hoffman
mhoffman@lightlink.com


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

end of thread, other threads:[~2007-10-23 11:27 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-17 19:29 [2.6 patch] hwmon/ibmpex.c: fix NULL dereference Adrian Bunk
2007-10-17 19:39 ` Nish Aravamudan
2007-10-17 19:50   ` Adrian Bunk
2007-10-17 20:58 ` [lm-sensors] " Jean Delvare
2007-10-17 22:15   ` [PATCH] ibmpex: Change printk to dev_{info,err} macros Darrick J. Wong
2007-10-19  8:54     ` Jean Delvare
2007-10-19 23:35       ` [PATCH v2] " Darrick J. Wong
2007-10-20 21:30         ` Jean Delvare
2007-10-23 11:23           ` Mark M. Hoffman
2007-10-17 21:10 ` [2.6 patch] hwmon/ibmpex.c: fix NULL dereference Darrick J. Wong
2007-10-18 13:34 ` Mark M. Hoffman

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).