[2/5] MEDIA: ttusbir, fix double free

Message ID 1365107532-32721-2-git-send-email-jslaby@suse.cz (mailing list archive)
State Accepted, archived
Headers

Commit Message

Jiri Slaby April 4, 2013, 8:32 p.m. UTC
  rc_unregister_device already calls rc_free_device to free the passed
device. But in one of ttusbir's probe fail paths, we call
rc_unregister_device _and_ rc_free_device. This is wrong and results
in a double free.

Instead, set rc to NULL resulting in rc_free_device being a noop.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Sean Young <sean@mess.org>
Cc: Mauro Carvalho Chehab <mchehab@redhat.com>
Cc: linux-media@vger.kernel.org
---
 drivers/media/rc/ttusbir.c | 1 +
 1 file changed, 1 insertion(+)
  

Comments

Sean Young April 9, 2013, 10:36 a.m. UTC | #1
On Thu, Apr 04, 2013 at 10:32:09PM +0200, Jiri Slaby wrote:
> rc_unregister_device already calls rc_free_device to free the passed
> device. But in one of ttusbir's probe fail paths, we call
> rc_unregister_device _and_ rc_free_device. This is wrong and results
> in a double free.
> 
> Instead, set rc to NULL resulting in rc_free_device being a noop.
> 
> Signed-off-by: Jiri Slaby <jslaby@suse.cz>
> Cc: Sean Young <sean@mess.org>
> Cc: Mauro Carvalho Chehab <mchehab@redhat.com>
> Cc: linux-media@vger.kernel.org
> ---
>  drivers/media/rc/ttusbir.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/media/rc/ttusbir.c b/drivers/media/rc/ttusbir.c
> index cf0d47f..891762d 100644
> --- a/drivers/media/rc/ttusbir.c
> +++ b/drivers/media/rc/ttusbir.c
> @@ -347,6 +347,7 @@ static int ttusbir_probe(struct usb_interface *intf,
>  	return 0;
>  out3:
>  	rc_unregister_device(rc);
> +	rc = NULL;
>  out2:
>  	led_classdev_unregister(&tt->led);
>  out:
> -- 

Acked-by: Sean Young <sean@mess.org>


Sean
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
  

Patch

diff --git a/drivers/media/rc/ttusbir.c b/drivers/media/rc/ttusbir.c
index cf0d47f..891762d 100644
--- a/drivers/media/rc/ttusbir.c
+++ b/drivers/media/rc/ttusbir.c
@@ -347,6 +347,7 @@  static int ttusbir_probe(struct usb_interface *intf,
 	return 0;
 out3:
 	rc_unregister_device(rc);
+	rc = NULL;
 out2:
 	led_classdev_unregister(&tt->led);
 out: