[PATCH] media: cx2341x: Check return value of cx2341x_api()

Daniil Dulov posted 1 patch 1 year, 12 months ago
drivers/media/common/cx2341x.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
[PATCH] media: cx2341x: Check return value of cx2341x_api()
Posted by Daniil Dulov 1 year, 12 months ago
cx2341x_api() may return an error, so add a check.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 45ad9f8b44b0 ("V4L/DVB (4202): allow selecting CX2341x port mode")
Signed-off-by: Daniil Dulov <d.dulov@aladdin.ru>
---
 drivers/media/common/cx2341x.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/media/common/cx2341x.c b/drivers/media/common/cx2341x.c
index 1f67e021138f..fa888d7c3988 100644
--- a/drivers/media/common/cx2341x.c
+++ b/drivers/media/common/cx2341x.c
@@ -1035,7 +1035,10 @@ int cx2341x_update(void *priv, cx2341x_mbox_func func,
 	};
 	int err;
 
-	cx2341x_api(priv, func, CX2341X_ENC_SET_OUTPUT_PORT, 2, new->port, 0);
+	err = cx2341x_api(priv, func, CX2341X_ENC_SET_OUTPUT_PORT, 2, new->port, 0);
+
+    if (err)
+	    return err;
 
 	if (!old ||
 	    CMP_FIELD(old, new, is_50hz)) {
-- 
2.25.1
Re: [PATCH] media: cx2341x: Check return value of cx2341x_api()
Posted by Hans Verkuil 1 year, 12 months ago
On 11/02/2024 16:06, Daniil Dulov wrote:
> cx2341x_api() may return an error, so add a check.
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> 
> Fixes: 45ad9f8b44b0 ("V4L/DVB (4202): allow selecting CX2341x port mode")
> Signed-off-by: Daniil Dulov <d.dulov@aladdin.ru>
> ---
>  drivers/media/common/cx2341x.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/common/cx2341x.c b/drivers/media/common/cx2341x.c
> index 1f67e021138f..fa888d7c3988 100644
> --- a/drivers/media/common/cx2341x.c
> +++ b/drivers/media/common/cx2341x.c
> @@ -1035,7 +1035,10 @@ int cx2341x_update(void *priv, cx2341x_mbox_func func,
>  	};
>  	int err;
>  
> -	cx2341x_api(priv, func, CX2341X_ENC_SET_OUTPUT_PORT, 2, new->port, 0);
> +	err = cx2341x_api(priv, func, CX2341X_ENC_SET_OUTPUT_PORT, 2, new->port, 0);
> +
> +    if (err)
> +	    return err;

Indentation is all over the place, please fix!

Regards,

	Hans

>  
>  	if (!old ||
>  	    CMP_FIELD(old, new, is_50hz)) {