mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] media: pvrusb2: fix null-ptr-deref in class_unregister()
@ 2019-06-05 13:08 Kefeng Wang
  2019-06-07 22:44 ` isely
  0 siblings, 1 reply; 2+ messages in thread
From: Kefeng Wang @ 2019-06-05 13:08 UTC (permalink / raw)
  To: Mike Isely, Mauro Carvalho Chehab, linux-media
  Cc: linux-kernel, Kefeng Wang, Hulk Robot

The class_ptr will be NULL if pvr2_sysfs_class_create() fails
in pvr_init(), when call pvr2_sysfs_class_destroy(), it will
lead to null-ptr-deref, fix it.

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 drivers/media/usb/pvrusb2/pvrusb2-sysfs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/media/usb/pvrusb2/pvrusb2-sysfs.c b/drivers/media/usb/pvrusb2/pvrusb2-sysfs.c
index 7bc6d090358e..b6c6b314fadc 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-sysfs.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-sysfs.c
@@ -802,7 +802,8 @@ struct pvr2_sysfs_class *pvr2_sysfs_class_create(void)
 void pvr2_sysfs_class_destroy(struct pvr2_sysfs_class *clp)
 {
 	pvr2_sysfs_trace("Unregistering pvr2_sysfs_class id=%p", clp);
-	class_unregister(&clp->class);
+	if (clp)
+		class_unregister(&clp->class);
 }
 
 
-- 
2.20.1


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

* Re: [PATCH] media: pvrusb2: fix null-ptr-deref in class_unregister()
  2019-06-05 13:08 [PATCH] media: pvrusb2: fix null-ptr-deref in class_unregister() Kefeng Wang
@ 2019-06-07 22:44 ` isely
  0 siblings, 0 replies; 2+ messages in thread
From: isely @ 2019-06-07 22:44 UTC (permalink / raw)
  To: Kefeng Wang
  Cc: Mauro Carvalho Chehab, linux-media, Linux Kernel Mailing List,
	Hulk Robot


Acked-By: Mike Isely <isely@pobox.com>

On Wed, 5 Jun 2019, Kefeng Wang wrote:

> The class_ptr will be NULL if pvr2_sysfs_class_create() fails
> in pvr_init(), when call pvr2_sysfs_class_destroy(), it will
> lead to null-ptr-deref, fix it.
> 
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> ---
>  drivers/media/usb/pvrusb2/pvrusb2-sysfs.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/usb/pvrusb2/pvrusb2-sysfs.c b/drivers/media/usb/pvrusb2/pvrusb2-sysfs.c
> index 7bc6d090358e..b6c6b314fadc 100644
> --- a/drivers/media/usb/pvrusb2/pvrusb2-sysfs.c
> +++ b/drivers/media/usb/pvrusb2/pvrusb2-sysfs.c
> @@ -802,7 +802,8 @@ struct pvr2_sysfs_class *pvr2_sysfs_class_create(void)
>  void pvr2_sysfs_class_destroy(struct pvr2_sysfs_class *clp)
>  {
>  	pvr2_sysfs_trace("Unregistering pvr2_sysfs_class id=%p", clp);
> -	class_unregister(&clp->class);
> +	if (clp)
> +		class_unregister(&clp->class);
>  }
>  
>  
> 

-- 

Mike Isely
isely @ isely (dot) net
PGP: 03 54 43 4D 75 E5 CC 92 71 16 01 E2 B5 F5 C1 E8

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

end of thread, other threads:[~2019-06-07 22:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-05 13:08 [PATCH] media: pvrusb2: fix null-ptr-deref in class_unregister() Kefeng Wang
2019-06-07 22:44 ` isely

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

all inboxes | Powered by JetHome®