diff mbox

[01/25] media: dvb_frontend: better document the -EPERM condition

Message ID 31b56d74c88c3d6a867468299e0498ebc15fcf63.1505933919.git.mchehab@s-opensource.com (mailing list archive)
State New, archived
Headers show

Commit Message

Mauro Carvalho Chehab Sept. 20, 2017, 7:11 p.m. UTC
Two readonly ioctls can't be allowed if the frontend device
is opened in read only mode. Explain why.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
---
 drivers/media/dvb-core/dvb_frontend.c | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

Comments

shuah Sept. 20, 2017, 9:29 p.m. UTC | #1
On 09/20/2017 01:11 PM, Mauro Carvalho Chehab wrote:
> Two readonly ioctls can't be allowed if the frontend device
> is opened in read only mode. Explain why.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
> ---
>  drivers/media/dvb-core/dvb_frontend.c | 20 +++++++++++++++++---
>  1 file changed, 17 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/media/dvb-core/dvb_frontend.c b/drivers/media/dvb-core/dvb_frontend.c
> index 01bd19fd4c57..7dda5acea3f2 100644
> --- a/drivers/media/dvb-core/dvb_frontend.c
> +++ b/drivers/media/dvb-core/dvb_frontend.c
> @@ -1940,9 +1940,23 @@ static int dvb_frontend_ioctl(struct file *file, unsigned int cmd, void *parg)
>  		return -ENODEV;
>  	}
>  
> -	if ((file->f_flags & O_ACCMODE) == O_RDONLY &&
> -	    (_IOC_DIR(cmd) != _IOC_READ || cmd == FE_GET_EVENT ||
> -	     cmd == FE_DISEQC_RECV_SLAVE_REPLY)) {
> +	/*
> +	 * If the frontend is opened in read-only mode, only the ioctls
> +	 * that don't interfere at the tune logic should be accepted.

Nit:

with the tune logic

> +	 * That allows an external application to monitor the DVB QoS and
> +	 * statistics parameters.
> +	 *> +	 * That matches all _IOR() ioctls, except for two special cases:
> +	 *   - FE_GET_EVENT is part of the tuning logic on a DVB application;
> +	 *   - FE_DISEQC_RECV_SLAVE_REPLY is part of DiSEqC 2.0
> +	 *     setup
> +	 * So, those two ioctls should also return -EPERM, as otherwise
> +	 * reading from them would interfere with a DVB tune application
> +	 */
> +	if ((file->f_flags & O_ACCMODE) == O_RDONLY
> +	    && (_IOC_DIR(cmd) != _IOC_READ
> +		|| cmd == FE_GET_EVENT
> +		|| cmd == FE_DISEQC_RECV_SLAVE_REPLY)) {
>  		up(&fepriv->sem);
>  		return -EPERM;
>  	}
> 

Same comment from your previous series. I started looking at
the old series and now the latest. Didn't realize the series
has been revised. :(

Looks good to me

Reviewed by: Shuah Khan <shuahkh@osg.samsung.com>

thanks,
-- Shuah
diff mbox

Patch

diff --git a/drivers/media/dvb-core/dvb_frontend.c b/drivers/media/dvb-core/dvb_frontend.c
index 01bd19fd4c57..7dda5acea3f2 100644
--- a/drivers/media/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb-core/dvb_frontend.c
@@ -1940,9 +1940,23 @@  static int dvb_frontend_ioctl(struct file *file, unsigned int cmd, void *parg)
 		return -ENODEV;
 	}
 
-	if ((file->f_flags & O_ACCMODE) == O_RDONLY &&
-	    (_IOC_DIR(cmd) != _IOC_READ || cmd == FE_GET_EVENT ||
-	     cmd == FE_DISEQC_RECV_SLAVE_REPLY)) {
+	/*
+	 * If the frontend is opened in read-only mode, only the ioctls
+	 * that don't interfere at the tune logic should be accepted.
+	 * That allows an external application to monitor the DVB QoS and
+	 * statistics parameters.
+	 *
+	 * That matches all _IOR() ioctls, except for two special cases:
+	 *   - FE_GET_EVENT is part of the tuning logic on a DVB application;
+	 *   - FE_DISEQC_RECV_SLAVE_REPLY is part of DiSEqC 2.0
+	 *     setup
+	 * So, those two ioctls should also return -EPERM, as otherwise
+	 * reading from them would interfere with a DVB tune application
+	 */
+	if ((file->f_flags & O_ACCMODE) == O_RDONLY
+	    && (_IOC_DIR(cmd) != _IOC_READ
+		|| cmd == FE_GET_EVENT
+		|| cmd == FE_DISEQC_RECV_SLAVE_REPLY)) {
 		up(&fepriv->sem);
 		return -EPERM;
 	}