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

[media] em28xx: fix incorrect s_ctrl error code and wrong call to res_free

Calling subdevs to handle s_ctrl returned a non-zero return code even if
everything went fine.

Calling STREAMOFF if no STREAMON happened earlier would hit a BUG_ON
in res_free.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

authored by

Hans Verkuil and committed by
Mauro Carvalho Chehab
3ea2b673 02ac0480

+9 -5
+9 -5
drivers/media/video/em28xx/em28xx-video.c
··· 1434 1434 1435 1435 /* It isn't an AC97 control. Sends it to the v4l2 dev interface */ 1436 1436 if (rc == 1) { 1437 - v4l2_device_call_all(&dev->v4l2_dev, 0, core, s_ctrl, ctrl); 1437 + rc = v4l2_device_call_until_err(&dev->v4l2_dev, 0, core, s_ctrl, ctrl); 1438 1438 1439 1439 /* 1440 1440 * In the case of non-AC97 volume controls, we still need ··· 1708 1708 fh, type, fh->resources, dev->resources); 1709 1709 1710 1710 if (fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) { 1711 - videobuf_streamoff(&fh->vb_vidq); 1712 - res_free(fh, EM28XX_RESOURCE_VIDEO); 1711 + if (res_check(fh, EM28XX_RESOURCE_VIDEO)) { 1712 + videobuf_streamoff(&fh->vb_vidq); 1713 + res_free(fh, EM28XX_RESOURCE_VIDEO); 1714 + } 1713 1715 } else if (fh->type == V4L2_BUF_TYPE_VBI_CAPTURE) { 1714 - videobuf_streamoff(&fh->vb_vbiq); 1715 - res_free(fh, EM28XX_RESOURCE_VBI); 1716 + if (res_check(fh, EM28XX_RESOURCE_VBI)) { 1717 + videobuf_streamoff(&fh->vb_vbiq); 1718 + res_free(fh, EM28XX_RESOURCE_VBI); 1719 + } 1716 1720 } 1717 1721 1718 1722 return 0;