Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

media: lirc: Fix error handling in lirc_register()

When cdev_device_add() failed, calling put_device() to explicitly
release dev->lirc_dev. Otherwise, it could cause the fault of the
reference count.

Found by code review.

Cc: stable@vger.kernel.org
Fixes: a6ddd4fecbb0 ("media: lirc: remove last remnants of lirc kapi")
Signed-off-by: Ma Ke <make24@iscas.ac.cn>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>

authored by

Ma Ke and committed by
Hans Verkuil
4f4098c5 2412f16c

+5 -4
+5 -4
drivers/media/rc/lirc_dev.c
··· 736 736 737 737 cdev_init(&dev->lirc_cdev, &lirc_fops); 738 738 739 + get_device(&dev->dev); 740 + 739 741 err = cdev_device_add(&dev->lirc_cdev, &dev->lirc_dev); 740 742 if (err) 741 - goto out_ida; 742 - 743 - get_device(&dev->dev); 743 + goto out_put_device; 744 744 745 745 switch (dev->driver_type) { 746 746 case RC_DRIVER_SCANCODE: ··· 764 764 765 765 return 0; 766 766 767 - out_ida: 767 + out_put_device: 768 + put_device(&dev->lirc_dev); 768 769 ida_free(&lirc_ida, minor); 769 770 return err; 770 771 }