public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] virtio: console: fix error handling in init() function
@ 2012-09-01 19:49 Alexey Khoroshilov
  2012-09-09 20:19 ` Amit Shah
  0 siblings, 1 reply; 3+ messages in thread
From: Alexey Khoroshilov @ 2012-09-01 19:49 UTC (permalink / raw)
  To: Amit Shah
  Cc: Alexey Khoroshilov, Arnd Bergmann, Greg Kroah-Hartman,
	virtualization, linux-kernel, ldv-project

If register_virtio_driver() fails, virtio-ports class is not destroyed.
The patch adds error handling of register_virtio_driver().

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
---
 drivers/char/virtio_console.c |   12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index cdf2f54..060a672 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -1941,7 +1941,17 @@ static int __init init(void)
 	INIT_LIST_HEAD(&pdrvdata.consoles);
 	INIT_LIST_HEAD(&pdrvdata.portdevs);
 
-	return register_virtio_driver(&virtio_console);
+	err = register_virtio_driver(&virtio_console);
+	if (err < 0) {
+		pr_err("Error %d registering virtio driver\n", err);
+		goto free;
+	}
+	return 0;
+free:
+	if (pdrvdata.debugfs_dir)
+		debugfs_remove_recursive(pdrvdata.debugfs_dir);
+	class_destroy(pdrvdata.class);
+	return err;
 }
 
 static void __exit fini(void)
-- 
1.7.9.5


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

* Re: [PATCH] virtio: console: fix error handling in init() function
  2012-09-01 19:49 [PATCH] virtio: console: fix error handling in init() function Alexey Khoroshilov
@ 2012-09-09 20:19 ` Amit Shah
  2012-09-10  2:19   ` Rusty Russell
  0 siblings, 1 reply; 3+ messages in thread
From: Amit Shah @ 2012-09-09 20:19 UTC (permalink / raw)
  To: Alexey Khoroshilov
  Cc: Arnd Bergmann, Greg Kroah-Hartman, virtualization, linux-kernel,
	ldv-project, Rusty Russell

Hi Alexey,

On (Sat) 01 Sep 2012 [23:49:37], Alexey Khoroshilov wrote:
> If register_virtio_driver() fails, virtio-ports class is not destroyed.
> The patch adds error handling of register_virtio_driver().
> 
> Found by Linux Driver Verification project (linuxtesting.org).
> 
> Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
> ---
>  drivers/char/virtio_console.c |   12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
> index cdf2f54..060a672 100644
> --- a/drivers/char/virtio_console.c
> +++ b/drivers/char/virtio_console.c
> @@ -1941,7 +1941,17 @@ static int __init init(void)
>  	INIT_LIST_HEAD(&pdrvdata.consoles);
>  	INIT_LIST_HEAD(&pdrvdata.portdevs);
>  
> -	return register_virtio_driver(&virtio_console);
> +	err = register_virtio_driver(&virtio_console);
> +	if (err < 0) {
> +		pr_err("Error %d registering virtio driver\n", err);
> +		goto free;
> +	}
> +	return 0;
> +free:
> +	if (pdrvdata.debugfs_dir)
> +		debugfs_remove_recursive(pdrvdata.debugfs_dir);
> +	class_destroy(pdrvdata.class);
> +	return err;
>  }
>  
>  static void __exit fini(void)

Patch looks good.

Acked-by: Amit Shah <amit.shah@redhat.com>

Rusty, please pick this up.

Thanks,
		Amit

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

* Re: [PATCH] virtio: console: fix error handling in init() function
  2012-09-09 20:19 ` Amit Shah
@ 2012-09-10  2:19   ` Rusty Russell
  0 siblings, 0 replies; 3+ messages in thread
From: Rusty Russell @ 2012-09-10  2:19 UTC (permalink / raw)
  To: Amit Shah, Alexey Khoroshilov
  Cc: Arnd Bergmann, Greg Kroah-Hartman, virtualization, linux-kernel,
	ldv-project

Amit Shah <amit.shah@redhat.com> writes:
> On (Sat) 01 Sep 2012 [23:49:37], Alexey Khoroshilov wrote:
>> If register_virtio_driver() fails, virtio-ports class is not destroyed.
>> The patch adds error handling of register_virtio_driver().
>> 
>> Found by Linux Driver Verification project (linuxtesting.org).
>> 
>> Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
>
> Acked-by: Amit Shah <amit.shah@redhat.com>
>
> Rusty, please pick this up.

Thanks for the CC.

Applied,
Rusty.

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

end of thread, other threads:[~2012-09-10  2:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-01 19:49 [PATCH] virtio: console: fix error handling in init() function Alexey Khoroshilov
2012-09-09 20:19 ` Amit Shah
2012-09-10  2:19   ` Rusty Russell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox