Re: BUG: double mutex_unlock in drivers/media/video/tlg2300/pd-video.c

From: Huang Shijie
Date: Mon Dec 13 2010 - 20:34:53 EST


Hi Strakh:

Thanks for your patch.

But I prefer to remove the mutex_unlock() in the pd_vidioc_s_fmt(),
since the pd_vidioc_s_fmt() is also called in restore_v4l2_context().

would you please change the patch?
I will ack it.

Best Regards
Huang Shijie


2010/12/13 Alexander Strakh <strakh@xxxxxxxxx>:
> Â Â Â ÂKERNEL_VERSION: 2.6.36
> Â Â Â ÂSUBJECT: double mutex_lock in drivers/media/video/tlg2300/pd-video.c
> in function vidioc_s_fmt
> Â Â Â ÂSUBSCRIBE:
> Â Â Â ÂFirst mutex_unlock in function pd_vidioc_s_fmt in line 767:
>
> Â764 Â Â Â Âret |= send_set_req(pd, VIDEO_ROSOLU_SEL,
> Â765 Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âvid_resol, &cmd_status);
> Â766 Â Â Â Âif (ret || cmd_status) {
> Â767 Â Â Â Â Â Â Â Âmutex_unlock(&pd->lock);
> Â768 Â Â Â Â Â Â Â Âreturn -EBUSY;
> Â769 Â Â Â Â}
>
> Â Â Â ÂSecond mutex_unlock in function vidioc_s_fmt in line 806:
>
> Â805 Â Â Â Âpd_vidioc_s_fmt(pd, &f->fmt.pix);
> Â806 Â Â Â Âmutex_unlock(&pd->lock);
>
> Found by Linux Device Drivers Verification Project
>
> Ðhecks the return code of pd_vidioc_s_fm before mutex_unlocking.
>
> Signed-off-by: Alexander Strakh <strakh@xxxxxxxxx>
>
> ---
> diff --git a/drivers/media/video/tlg2300/pd-video.c
> b/drivers/media/video/tlg2300/pd-video.c
> index a1ffe18..fe6bd2b 100644
> --- a/drivers/media/video/tlg2300/pd-video.c
> +++ b/drivers/media/video/tlg2300/pd-video.c
> @@ -802,8 +802,8 @@ static int vidioc_s_fmt(struct file *file, void *fh,
> struct v4l2_format *f)
> Â Â Â Â Â Â Â Âreturn -EINVAL;
> Â Â Â Â}
>
> - Â Â Â pd_vidioc_s_fmt(pd, &f->fmt.pix);
> - Â Â Â mutex_unlock(&pd->lock);
> + Â Â Â if(!pd_vidioc_s_fmt(pd, &f->fmt.pix))
> + Â Â Â Â Â Â Â mutex_unlock(&pd->lock);
> Â Â Â Âreturn 0;
> Â}
>
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/