From patchwork Tue Jun 14 07:14:42 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 878082 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p5E7ErJJ023258 for ; Tue, 14 Jun 2011 07:15:50 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754593Ab1FNHPA (ORCPT ); Tue, 14 Jun 2011 03:15:00 -0400 Received: from smtp-vbr6.xs4all.nl ([194.109.24.26]:2885 "EHLO smtp-vbr6.xs4all.nl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754518Ab1FNHO4 (ORCPT ); Tue, 14 Jun 2011 03:14:56 -0400 Received: from tschai (64-103-25-233.cisco.com [64.103.25.233]) (authenticated bits=0) by smtp-vbr6.xs4all.nl (8.13.8/8.13.8) with ESMTP id p5E7EjiK075823 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 14 Jun 2011 09:14:53 +0200 (CEST) (envelope-from hverkuil@xs4all.nl) From: Hans Verkuil To: linux-media@vger.kernel.org Cc: Mike Isely , Hans Verkuil Subject: [RFCv6 PATCH 10/10] v4l2-ioctl.c: check for valid tuner type in S_HW_FREQ_SEEK. Date: Tue, 14 Jun 2011 09:14:42 +0200 Message-Id: X-Mailer: git-send-email 1.7.1 In-Reply-To: <1308035682-20447-1-git-send-email-hverkuil@xs4all.nl> References: <1308035682-20447-1-git-send-email-hverkuil@xs4all.nl> In-Reply-To: References: X-Virus-Scanned: by XS4ALL Virus Scanner Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Tue, 14 Jun 2011 07:15:50 +0000 (UTC) From: Hans Verkuil Prohibit attempts to change the tuner to a type that is different from the device node the ioctl is called from. I.e. the type must be RADIO for a radio node and ANALOG_TV for a video/vbi node. Signed-off-by: Hans Verkuil --- drivers/media/video/v4l2-ioctl.c | 12 +++++++++--- 1 files changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-ioctl.c index 26bf3bf..55df143 100644 --- a/drivers/media/video/v4l2-ioctl.c +++ b/drivers/media/video/v4l2-ioctl.c @@ -1946,13 +1946,19 @@ static long __video_do_ioctl(struct file *file, case VIDIOC_S_HW_FREQ_SEEK: { struct v4l2_hw_freq_seek *p = arg; + enum v4l2_tuner_type type; if (!ops->vidioc_s_hw_freq_seek) break; + type = (vfd->vfl_type == VFL_TYPE_RADIO) ? + V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; dbgarg(cmd, - "tuner=%d, type=%d, seek_upward=%d, wrap_around=%d\n", - p->tuner, p->type, p->seek_upward, p->wrap_around); - ret = ops->vidioc_s_hw_freq_seek(file, fh, p); + "tuner=%u, type=%u, seek_upward=%u, wrap_around=%u, spacing=%u\n", + p->tuner, p->type, p->seek_upward, p->wrap_around, p->spacing); + if (p->type != type) + ret = -EINVAL; + else + ret = ops->vidioc_s_hw_freq_seek(file, fh, p); break; } case VIDIOC_ENUM_FRAMESIZES: