From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EC0AD2F80 for ; Thu, 10 Jun 2021 21:45:03 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 19B1F613CA; Thu, 10 Jun 2021 21:45:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1623361503; bh=P0W2KJ4lzuzwWS6G/VqMgKtWboi7bu1bEPiy8Gk27bA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bk+P31Vcczg79DOEhKZYLisjfWMS1pomZiAAU6ijgXlVDNL419cxL0Ic3e+ajxpQt VEjQUmlUnmuaAr8tbZ7uFUohE9EEY5zJawTfyO3VJbC6FIVu1WHSYXTmCNWQKn4uEU lbjRyvYti+7w2lUQd1e4/Z60ZbjyvwvO3zAHllXBscZo02phLxDMk4PwEDE4O3aJM0 TLSZXLCuNjMu+OgbFSaZjGf2brQPx/kszy4OaIIwIegN1hLeYeFrUisfbe5n7pLGEI EmaT9Th2KRaqom9BjblutrBcd2+TRIYjkMVeFFVUyqVjKJlC5noWmWQ1uUZtM12TmZ l4tsbpLM8WL3Q== From: Arnd Bergmann To: Hans Verkuil , Mauro Carvalho Chehab Cc: Arnd Bergmann , "Lad, Prabhakar" , Eduardo Valentin , Sakari Ailus , Greg Kroah-Hartman , Vaibhav Gupta , Liu Shixin , Laurent Pinchart , Jacopo Mondi , Andy Shevchenko , linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH v2 4/7] media: v4l2-core: return -ENODEV from ioctl when not registered Date: Thu, 10 Jun 2021 23:43:02 +0200 Message-Id: <20210610214305.4170835-5-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210610214305.4170835-1-arnd@kernel.org> References: <20210610214305.4170835-1-arnd@kernel.org> X-Mailing-List: linux-staging@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Arnd Bergmann I spotted a minor difference is handling of unregistered devices between native and compat ioctls: the native handler never tries to call into the driver if a device is not marked as registered. I did not check whether this can cause issues in the kernel, or just a different between return codes, but it clearly makes sense that both should behave the same way. Signed-off-by: Arnd Bergmann --- drivers/media/v4l2-core/v4l2-compat-ioctl32.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c index 0ca75f6784c5..47aff3b19742 100644 --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c @@ -1244,6 +1244,9 @@ long v4l2_compat_ioctl32(struct file *file, unsigned int cmd, unsigned long arg) if (!file->f_op->unlocked_ioctl) return ret; + if (!video_is_registered(vdev)) + return -ENODEV; + if (_IOC_TYPE(cmd) == 'V' && _IOC_NR(cmd) < BASE_VIDIOC_PRIVATE) ret = file->f_op->unlocked_ioctl(file, cmd, (unsigned long)compat_ptr(arg)); -- 2.29.2