diff options
author | Frank Schaefer <fschaefer.oss@googlemail.com> | 2014-01-12 11:24:25 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <m.chehab@samsung.com> | 2014-01-14 11:32:12 -0500 |
commit | e847022a8e1d732da96ddbd8d4170500f4c3f8b1 (patch) | |
tree | abe97b3d5d3b2cf940c67487b3aff171ba39b882 /drivers/media/usb | |
parent | 5a620c7c1cd74064e75a525738e9410b8851fa96 (diff) |
[media] em28xx-v4l: fix the freeing of the video devices memory
Remove some dead code from em28xx_v4l2_fini() and fix the leaking of the video,
vbi and radio video_device struct memories.
Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Diffstat (limited to 'drivers/media/usb')
-rw-r--r-- | drivers/media/usb/em28xx/em28xx-video.c | 56 |
1 files changed, 30 insertions, 26 deletions
diff --git a/drivers/media/usb/em28xx/em28xx-video.c b/drivers/media/usb/em28xx/em28xx-video.c index cda0dc3555d2..587ff3fe9402 100644 --- a/drivers/media/usb/em28xx/em28xx-video.c +++ b/drivers/media/usb/em28xx/em28xx-video.c | |||
@@ -1899,29 +1899,19 @@ static int em28xx_v4l2_fini(struct em28xx *dev) | |||
1899 | em28xx_uninit_usb_xfer(dev, EM28XX_ANALOG_MODE); | 1899 | em28xx_uninit_usb_xfer(dev, EM28XX_ANALOG_MODE); |
1900 | 1900 | ||
1901 | if (dev->radio_dev) { | 1901 | if (dev->radio_dev) { |
1902 | if (video_is_registered(dev->radio_dev)) | 1902 | em28xx_info("V4L2 device %s deregistered\n", |
1903 | video_unregister_device(dev->radio_dev); | 1903 | video_device_node_name(dev->radio_dev)); |
1904 | else | 1904 | video_unregister_device(dev->radio_dev); |
1905 | video_device_release(dev->radio_dev); | ||
1906 | dev->radio_dev = NULL; | ||
1907 | } | 1905 | } |
1908 | if (dev->vbi_dev) { | 1906 | if (dev->vbi_dev) { |
1909 | em28xx_info("V4L2 device %s deregistered\n", | 1907 | em28xx_info("V4L2 device %s deregistered\n", |
1910 | video_device_node_name(dev->vbi_dev)); | 1908 | video_device_node_name(dev->vbi_dev)); |
1911 | if (video_is_registered(dev->vbi_dev)) | 1909 | video_unregister_device(dev->vbi_dev); |
1912 | video_unregister_device(dev->vbi_dev); | ||
1913 | else | ||
1914 | video_device_release(dev->vbi_dev); | ||
1915 | dev->vbi_dev = NULL; | ||
1916 | } | 1910 | } |
1917 | if (dev->vdev) { | 1911 | if (dev->vdev) { |
1918 | em28xx_info("V4L2 device %s deregistered\n", | 1912 | em28xx_info("V4L2 device %s deregistered\n", |
1919 | video_device_node_name(dev->vdev)); | 1913 | video_device_node_name(dev->vdev)); |
1920 | if (video_is_registered(dev->vdev)) | 1914 | video_unregister_device(dev->vdev); |
1921 | video_unregister_device(dev->vdev); | ||
1922 | else | ||
1923 | video_device_release(dev->vdev); | ||
1924 | dev->vdev = NULL; | ||
1925 | } | 1915 | } |
1926 | 1916 | ||
1927 | if (dev->clk) { | 1917 | if (dev->clk) { |
@@ -1955,9 +1945,7 @@ static int em28xx_v4l2_close(struct file *filp) | |||
1955 | mutex_lock(&dev->lock); | 1945 | mutex_lock(&dev->lock); |
1956 | 1946 | ||
1957 | if (dev->users == 1) { | 1947 | if (dev->users == 1) { |
1958 | /* the device is already disconnect, | 1948 | /* free the remaining resources if device is disconnected */ |
1959 | free the remaining resources */ | ||
1960 | |||
1961 | if (dev->disconnected) { | 1949 | if (dev->disconnected) { |
1962 | kfree(dev->alt_max_pkt_size_isoc); | 1950 | kfree(dev->alt_max_pkt_size_isoc); |
1963 | goto exit; | 1951 | goto exit; |
@@ -1985,6 +1973,23 @@ exit: | |||
1985 | return 0; | 1973 | return 0; |
1986 | } | 1974 | } |
1987 | 1975 | ||
1976 | /* | ||
1977 | * em28xx_videodevice_release() | ||
1978 | * called when the last user of the video device exits and frees the memeory | ||
1979 | */ | ||
1980 | static void em28xx_videodevice_release(struct video_device *vdev) | ||
1981 | { | ||
1982 | struct em28xx *dev = video_get_drvdata(vdev); | ||
1983 | |||
1984 | video_device_release(vdev); | ||
1985 | if (vdev == dev->vdev) | ||
1986 | dev->vdev = NULL; | ||
1987 | else if (vdev == dev->vbi_dev) | ||
1988 | dev->vbi_dev = NULL; | ||
1989 | else if (vdev == dev->radio_dev) | ||
1990 | dev->radio_dev = NULL; | ||
1991 | } | ||
1992 | |||
1988 | static const struct v4l2_file_operations em28xx_v4l_fops = { | 1993 | static const struct v4l2_file_operations em28xx_v4l_fops = { |
1989 | .owner = THIS_MODULE, | 1994 | .owner = THIS_MODULE, |
1990 | .open = em28xx_v4l2_open, | 1995 | .open = em28xx_v4l2_open, |
@@ -2039,11 +2044,10 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = { | |||
2039 | }; | 2044 | }; |
2040 | 2045 | ||
2041 | static const struct video_device em28xx_video_template = { | 2046 | static const struct video_device em28xx_video_template = { |
2042 | .fops = &em28xx_v4l_fops, | 2047 | .fops = &em28xx_v4l_fops, |
2043 | .release = video_device_release_empty, | 2048 | .ioctl_ops = &video_ioctl_ops, |
2044 | .ioctl_ops = &video_ioctl_ops, | 2049 | .release = em28xx_videodevice_release, |
2045 | 2050 | .tvnorms = V4L2_STD_ALL, | |
2046 | .tvnorms = V4L2_STD_ALL, | ||
2047 | }; | 2051 | }; |
2048 | 2052 | ||
2049 | static const struct v4l2_file_operations radio_fops = { | 2053 | static const struct v4l2_file_operations radio_fops = { |
@@ -2069,9 +2073,9 @@ static const struct v4l2_ioctl_ops radio_ioctl_ops = { | |||
2069 | }; | 2073 | }; |
2070 | 2074 | ||
2071 | static struct video_device em28xx_radio_template = { | 2075 | static struct video_device em28xx_radio_template = { |
2072 | .name = "em28xx-radio", | 2076 | .fops = &radio_fops, |
2073 | .fops = &radio_fops, | 2077 | .ioctl_ops = &radio_ioctl_ops, |
2074 | .ioctl_ops = &radio_ioctl_ops, | 2078 | .release = em28xx_videodevice_release, |
2075 | }; | 2079 | }; |
2076 | 2080 | ||
2077 | /* I2C possible address to saa7115, tvp5150, msp3400, tvaudio */ | 2081 | /* I2C possible address to saa7115, tvp5150, msp3400, tvaudio */ |