From patchwork Mon Nov 6 12:25:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 741657 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 23BA2C4167B for ; Mon, 6 Nov 2023 12:26:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231726AbjKFM0I (ORCPT ); Mon, 6 Nov 2023 07:26:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231701AbjKFM0I (ORCPT ); Mon, 6 Nov 2023 07:26:08 -0500 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F18AA4 for ; Mon, 6 Nov 2023 04:26:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1699273565; x=1730809565; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=QHliufb3LuMrw/zBCGrBLQB45gKgEq9rN2vOBu6Li40=; b=cxXk3SaONatAcH0L6ZjIkLeoxmJJCYK65OEXMR4IZxxzNueU0s2Tks9M 3Fc9OHZ+tEMsrqm4w/p1fbdN2fjMo4y8Nvnmw92vKpR8TB3X/j3pJF2WT 4Q+A9kv0yxK4ZUt66ZOrHBrXifuGcyyCnfWQKyeyKfT0VlwUJP1/fR7zh RtBe6UIa9MZh+dilqkfET7Zzsc/+RPT7QiWZ5e6zJ/WAOua05LcyjNNnn gmDA5Lv6qFT+joEqMmcmoLPEjcarVbsfVhOnNWgYyBwO3nDJV6xG51L2a HIKif0gDXjgpb5J51wbk58VLFjoGx4UdFN5ojwFRKmej1ixDQtuZrNWwv g==; X-IronPort-AV: E=McAfee;i="6600,9927,10885"; a="455747275" X-IronPort-AV: E=Sophos;i="6.03,281,1694761200"; d="scan'208";a="455747275" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Nov 2023 04:26:05 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10885"; a="797291620" X-IronPort-AV: E=Sophos;i="6.03,281,1694761200"; d="scan'208";a="797291620" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Nov 2023 04:26:02 -0800 Received: from svinhufvud.ger.corp.intel.com (localhost [IPv6:::1]) by kekkonen.fi.intel.com (Postfix) with ESMTP id E25831202BB; Mon, 6 Nov 2023 14:25:58 +0200 (EET) From: Sakari Ailus To: linux-media@vger.kernel.org Cc: Laurent Pinchart , tomi.valkeinen@ideasonboard.com, bingbu.cao@intel.com, hongju.wang@intel.com, hverkuil@xs4all.nl, Andrey Konovalov , Jacopo Mondi , Dmitry Perchanov , "Ng, Khai Wen" , Alain Volmat Subject: [PATCH v7 13/31] media: v4l: subdev: Copy argument back to user also for S_ROUTING Date: Mon, 6 Nov 2023 14:25:21 +0200 Message-Id: <20231106122539.1268265-14-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231106122539.1268265-1-sakari.ailus@linux.intel.com> References: <20231106122539.1268265-1-sakari.ailus@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org As the user needs to know what went wrong for S_ROUTING, copy array arguments back to the user. Signed-off-by: Sakari Ailus --- drivers/media/v4l2-core/v4l2-ioctl.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c index fb453b7d0c91..bf02c3f55370 100644 --- a/drivers/media/v4l2-core/v4l2-ioctl.c +++ b/drivers/media/v4l2-core/v4l2-ioctl.c @@ -3415,11 +3415,14 @@ video_usercopy(struct file *file, unsigned int orig_cmd, unsigned long arg, * FIXME: subdev IOCTLS are partially handled here and partially in * v4l2-subdev.c and the 'always_copy' flag can only be set for IOCTLS * defined here as part of the 'v4l2_ioctls' array. As - * VIDIOC_SUBDEV_G_ROUTING needs to return results to applications even - * in case of failure, but it is not defined here as part of the + * VIDIOC_SUBDEV_[GS]_ROUTING needs to return results to applications + * even in case of failure, but it is not defined here as part of the * 'v4l2_ioctls' array, insert an ad-hoc check to address that. */ - if (err < 0 && !always_copy && cmd != VIDIOC_SUBDEV_G_ROUTING) + if (cmd == VIDIOC_SUBDEV_G_ROUTING || cmd == VIDIOC_SUBDEV_S_ROUTING) + always_copy = true; + + if (err < 0 && !always_copy) goto out; if (has_array_args) {