From patchwork Mon Jun 14 10:34:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 459803 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp3161524jae; Mon, 14 Jun 2021 03:44:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwB1qceU2B+cez3AcvHwdXXmbuc8RKvRpGAYPku41HEY0QXVm3PILaXSruPtJkjPJMauaBy X-Received: by 2002:a17:906:3e8d:: with SMTP id a13mr14562470ejj.463.1623667496573; Mon, 14 Jun 2021 03:44:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623667496; cv=none; d=google.com; s=arc-20160816; b=guf4oH4nXhCzWg72bYQZ4NReIo4u3yrSuPRqNLbEKW54YoYtktTDLU0vaVMUGKowfj H+IXiWRF1YF3bGh9eZl6QAl9+5RSyxRs28N2723z47uddGfWMF3y3XSmDU0czgCLCeg7 KDR1ZKOwj5p5M7Xi4f30235694JQquM0BNDeOTLTC5NtFcPyzwd2xMpbkwXamHzUDTXS hbDVT4BJPfCGJVFbEbsgGTwdvmcda+GOjGrffLXSm7b5BQAY5djyEkp/VLgid+AXdAcz TH1xexh7AiCNW5/ODAkGeQcKJnWRuLcJUnHzgVflgnZlQNGblnn+CVx79W27FSEJIVQ+ hILg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=JxB2SuRppArzh4BKAjO3t8SyLJIEZgLApk6uXXf9wkg=; b=xDzNMvZ3bhSW0r112oRi+ZdCPkcHDKy1cVPzo6cA7zB4ILrgtEslmw7TmqKOuFNLtG DegjwxGrhnvqSp5e6LSB6zB95PoSvWN22Q4wHryYhX+qmdajcyjKgjwHhPBwY2is/FDK Nwr2r7McDvt9h7Q3s+ygB8z3GB7PEnEq+6wcjmV+83kGAu86veAj3oqfNh1q5hf1P601 Qg8FOJIJYpODWe3KREx8V5gCDuB27PeFBfnggAezpriOE4GEWxiRWU6xI7rxMjc4QQaP J22DUuli6t6b8bu2fL6Jekh1ljNYIuRyG+sDDu5kDzP1fU+s9tEmzjv/7mgpcCW6CfoE 2oag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Vy10f0wk; spf=pass (google.com: domain of linux-media-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w19si10609433edc.458.2021.06.14.03.44.56; Mon, 14 Jun 2021 03:44:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-media-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Vy10f0wk; spf=pass (google.com: domain of linux-media-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233932AbhFNKqr (ORCPT + 4 others); Mon, 14 Jun 2021 06:46:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:47328 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234213AbhFNKok (ORCPT ); Mon, 14 Jun 2021 06:44:40 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6B1E0613CD; Mon, 14 Jun 2021 10:36:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1623666983; bh=P0W2KJ4lzuzwWS6G/VqMgKtWboi7bu1bEPiy8Gk27bA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vy10f0wkFU3txmJ8kgjyzUrNBuxT/DBfVmJegIcch3iem4cahktTb8xQiQD24K6Jl RG2zsJXO2w2EbtwsCiFqZ/tOwkQvVPtKzzRPjQGEReZsj4M6rS337/3XSBNUdrJ9Jh HHSt3k2IzRcOCSAyPLeFnLr4ey8U3/9j1M7ZCBNA8HyRBbGrsyN/zUDQU2OZ2zhZDE M3ONZycEGqH/g09Cr+ui/jLsbWhSKDWK2skIckxD1EFkSJWTogDSqnv2H2YznqUlXy WJvK3TpULrCLtIjQtuKsCHzNzYmdUwX97HacrofJwOE7HIrbsfw14sElJ4hFomIJ1b pUoJ2X/XECoxw== 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 v3 5/8] media: v4l2-core: return -ENODEV from ioctl when not registered Date: Mon, 14 Jun 2021 12:34:06 +0200 Message-Id: <20210614103409.3154127-6-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210614103409.3154127-1-arnd@kernel.org> References: <20210614103409.3154127-1-arnd@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org 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(+) -- 2.29.2 Reviewed-by: Laurent Pinchart Reviewed-by: Laurent Pinchart 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));