From 06a3e0dc829a015ef4b76d4e016df13b0be89e46 Mon Sep 17 00:00:00 2001 From: Michael Krufky Date: Tue, 18 Jul 2006 16:17:56 -0300 Subject: pvrusb2: check the return value of class_device_register From: Michael Krufky If an error occurs during class_device_register, print an error message, kfree(class_dev) and return. Signed-off-by: Michael Krufky --- linux/drivers/media/video/pvrusb2/pvrusb2-sysfs.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'linux/drivers/media/video/pvrusb2/pvrusb2-sysfs.c') diff --git a/linux/drivers/media/video/pvrusb2/pvrusb2-sysfs.c b/linux/drivers/media/video/pvrusb2/pvrusb2-sysfs.c index 4770bc3be..045f2d585 100644 --- a/linux/drivers/media/video/pvrusb2/pvrusb2-sysfs.c +++ b/linux/drivers/media/video/pvrusb2/pvrusb2-sysfs.c @@ -710,6 +710,8 @@ static void class_dev_create(struct pvr2_sysfs *sfp, { struct usb_device *usb_dev; struct class_device *class_dev; + int ret; + usb_dev = pvr2_hdw_get_dev(sfp->channel.hdw); if (!usb_dev) return; class_dev = kmalloc(sizeof(*class_dev),GFP_KERNEL); @@ -734,7 +736,13 @@ static void class_dev_create(struct pvr2_sysfs *sfp, sfp->class_dev = class_dev; class_dev->class_data = sfp; - class_device_register(class_dev); + ret = class_device_register(class_dev); + if (ret) { + printk(KERN_ERR "%s: class_device_register failed\n", + __FUNCTION__); + kfree(class_dev); + return; + } sfp->attr_v4l_minor_number.attr.owner = THIS_MODULE; sfp->attr_v4l_minor_number.attr.name = "v4l_minor_number"; -- cgit v1.2.3