Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp253899yba; Wed, 15 May 2019 00:17:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqxRXr69zfPYDm+0M8EZoKzSpVdO8TV02bsQks+vsBQzVJ8D/IrsP0aNuUweTaswvKDpLqW7 X-Received: by 2002:a65:64da:: with SMTP id t26mr42695822pgv.322.1557904648728; Wed, 15 May 2019 00:17:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557904648; cv=none; d=google.com; s=arc-20160816; b=IiXLrUKZOl/4+vwB7u7BdcwfQp73DO7OkfMpBa4MTWGvsodQscienUmdF3Gt4r9KN0 DLI7QsawPh1nE3KJrJ34KeOgqgEZB441keVn8kcc7BjGQMSFVPj+ZOKf6vDEaeApAL+Z eOWG/6ecfw4Dd/ymIJUmHWmi2p2JW5IuxEYAu/tJctOV6l4UwFKyWdDgFAQgujjMXUrx Ay8Oe/+ZbXMboRF6ChVjpm/zxyodxKy2OYyvHantVmWDcr/n/9DMydzl07e6XS7liJah X2p4aIm/4Om/ZM25B8keb3ZqR/8/U4dW70GSwOPvOex1bLZO45RMiwaov4Wk/6k7v9P6 JNkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=4VgVGCFpd8De/4QJKCx033fPbuLShYabgrzNCbHG6hY=; b=nLkT1HbMoPkYVu9Hvcsvjq0RajLIsKHI3QGAL7/mWUFFG7zq76Dl46ok3uil6oIqYY COlIqpVwXPFXRb+IrSWzR5mjVjWxhLhwEzEB+VgFscMgdD39aTnoUBbu0qh0mSPA9AlP INJ2h4S2Rm3u+2UTeM1xinxXjGkYUDeFfpkGBgAthBZLP0SuzscHMC337NI5Y6E/N3K1 Cv1kOWv/kMI80/EnGKIQnCbLClXK5lXHnoj6WGsHeqJcUclj1IaYgIg+q8QVp14pBv4N F+npMjtmTMzlW+KXbM8aHBE/nRxaZuHagL1HoEFNB41Yo24tti8ifNdoa9oHHT8bGxCd Pqcg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z33si1083770pgk.516.2019.05.15.00.17.13; Wed, 15 May 2019 00:17:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726283AbfEOHQG (ORCPT + 99 others); Wed, 15 May 2019 03:16:06 -0400 Received: from mga17.intel.com ([192.55.52.151]:38503 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726039AbfEOHQG (ORCPT ); Wed, 15 May 2019 03:16:06 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 May 2019 00:16:06 -0700 X-ExtLoop1: 1 Received: from paasikivi.fi.intel.com ([10.237.72.42]) by fmsmga008.fm.intel.com with ESMTP; 15 May 2019 00:16:02 -0700 Received: by paasikivi.fi.intel.com (Postfix, from userid 1000) id 223C720417; Wed, 15 May 2019 10:16:02 +0300 (EEST) Date: Wed, 15 May 2019 10:16:02 +0300 From: Sakari Ailus To: Janusz Krzysztofik Cc: Mauro Carvalho Chehab , Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v6 1/3] media: v4l2-subdev: Verify arguments in v4l2_subdev_call() Message-ID: <20190515071601.knfdhwofz6ukjmxt@paasikivi.fi.intel.com> References: <20190514224823.11564-1-jmkrzyszt@gmail.com> <20190514224823.11564-2-jmkrzyszt@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190514224823.11564-2-jmkrzyszt@gmail.com> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Janusz, On Wed, May 15, 2019 at 12:48:21AM +0200, Janusz Krzysztofik wrote: > -static int check_crop(struct v4l2_subdev *sd, struct v4l2_subdev_crop *crop) > +static inline int check_pad(struct v4l2_subdev *sd, __u32 pad) > { > - if (crop->which != V4L2_SUBDEV_FORMAT_TRY && > - crop->which != V4L2_SUBDEV_FORMAT_ACTIVE) > +#if defined(CONFIG_MEDIA_CONTROLLER) > + if (sd->entity.num_pads && pad >= sd->entity.num_pads) One more comment. The num_pads doesn't really tell whether a given op is valid for a device. Well, in this case it would have to be a bug in the driver, but those do happen. How about checking for sd->entity.graph_obj.mdev instead? It's non-NULL if the entity is registered with a media device, i.e. when these callback functions are supposed to be called. -- Sakari Ailus sakari.ailus@linux.intel.com