diff mbox

[SRU,Precise,1/1] Drivers: hv: vmbus: incorrect device name is printed when child device is unregistered

Message ID 49e6c437b977b330f78857ebc3ba3c6f3e6ada5d.1425411559.git.joseph.salisbury@canonical.com
State New
Headers show

Commit Message

Joseph Salisbury March 3, 2015, 7:53 p.m. UTC
From: Fernando Soto <fsoto@bluecatnetworks.com>

BugLink: http://bugs.launchpad.net/bugs/1417313

Whenever a device is unregistered in vmbus_device_unregister (drivers/hv/vmbus_drv.c), the device name in the log message may contain garbage as the memory has already been freed by the time pr_info is called. Log example:
 [ 3149.170475] hv_vmbus: child device àõsèè0_5 unregistered

By logging the message just before calling device_unregister, the correct device name is printed:
[ 3145.034652] hv_vmbus: child device vmbus_0_5 unregistered

Also changing register & unregister messages to debug to avoid unnecessarily cluttering the kernel log.

Signed-off-by: Fernando M Soto <fsoto@bluecatnetworks.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 84672369ffb98a51d4ddf74c20a23636da3ad615)
Signed-off-by: Joseph Salisbury <joseph.salisbury@canonical.com>
---
 drivers/hv/vmbus_drv.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Stefan Bader March 5, 2015, 1:49 p.m. UTC | #1
Seems to do what it claims
Andy Whitcroft March 9, 2015, 1:39 p.m. UTC | #2
On Tue, Mar 03, 2015 at 02:53:38PM -0500, Joseph Salisbury wrote:
> From: Fernando Soto <fsoto@bluecatnetworks.com>
> 
> BugLink: http://bugs.launchpad.net/bugs/1417313
> 
> Whenever a device is unregistered in vmbus_device_unregister (drivers/hv/vmbus_drv.c), the device name in the log message may contain garbage as the memory has already been freed by the time pr_info is called. Log example:
>  [ 3149.170475] hv_vmbus: child device àõsèè0_5 unregistered
> 
> By logging the message just before calling device_unregister, the correct device name is printed:
> [ 3145.034652] hv_vmbus: child device vmbus_0_5 unregistered
> 
> Also changing register & unregister messages to debug to avoid unnecessarily cluttering the kernel log.
> 
> Signed-off-by: Fernando M Soto <fsoto@bluecatnetworks.com>
> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> (cherry picked from commit 84672369ffb98a51d4ddf74c20a23636da3ad615)
> Signed-off-by: Joseph Salisbury <joseph.salisbury@canonical.com>
> ---
>  drivers/hv/vmbus_drv.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
> index 10619b3..1ec309d 100644
> --- a/drivers/hv/vmbus_drv.c
> +++ b/drivers/hv/vmbus_drv.c
> @@ -681,7 +681,7 @@ int vmbus_device_register(struct hv_device *child_device_obj)
>  	if (ret)
>  		pr_err("Unable to register child device\n");
>  	else
> -		pr_info("child device %s registered\n",
> +		pr_debug("child device %s registered\n",
>  			dev_name(&child_device_obj->device));
>  
>  	return ret;
> @@ -693,14 +693,14 @@ int vmbus_device_register(struct hv_device *child_device_obj)
>   */
>  void vmbus_device_unregister(struct hv_device *device_obj)
>  {
> +	pr_debug("child device %s unregistered\n",
> +		dev_name(&device_obj->device));
> +
>  	/*
>  	 * Kick off the process of unregistering the device.
>  	 * This will call vmbus_remove() and eventually vmbus_device_release()
>  	 */
>  	device_unregister(&device_obj->device);
> -
> -	pr_info("child device %s unregistered\n",
> -		dev_name(&device_obj->device));
>  }

Although this does also seem to move these messages from info to debug
level this does match the upstream change.  Therefore:

Acked-by: Andy Whitcroft <apw@canonical.com>

-apw
diff mbox

Patch

diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index 10619b3..1ec309d 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -681,7 +681,7 @@  int vmbus_device_register(struct hv_device *child_device_obj)
 	if (ret)
 		pr_err("Unable to register child device\n");
 	else
-		pr_info("child device %s registered\n",
+		pr_debug("child device %s registered\n",
 			dev_name(&child_device_obj->device));
 
 	return ret;
@@ -693,14 +693,14 @@  int vmbus_device_register(struct hv_device *child_device_obj)
  */
 void vmbus_device_unregister(struct hv_device *device_obj)
 {
+	pr_debug("child device %s unregistered\n",
+		dev_name(&device_obj->device));
+
 	/*
 	 * Kick off the process of unregistering the device.
 	 * This will call vmbus_remove() and eventually vmbus_device_release()
 	 */
 	device_unregister(&device_obj->device);
-
-	pr_info("child device %s unregistered\n",
-		dev_name(&device_obj->device));
 }