[PATCH] staging: vc04_services: Delete unnecessary NULL check

Dan Carpenter posted 1 patch 1 year, 9 months ago
.../staging/vc04_services/interface/vchiq_arm/vchiq_dev.c    | 5 -----
1 file changed, 5 deletions(-)
[PATCH] staging: vc04_services: Delete unnecessary NULL check
Posted by Dan Carpenter 1 year, 9 months ago
The "state" pointer points to an offset in the middle of the "mgmt"
struct so it can't possibly be NULL.  And also we dereferenced it on the
line before.  So this NULL check is pointless.  Delete it.

Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 .../staging/vc04_services/interface/vchiq_arm/vchiq_dev.c    | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c
index 9fe35864936c..3c63347d2d08 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c
@@ -1170,11 +1170,6 @@ static int vchiq_open(struct inode *inode, struct file *file)
 
 	dev_dbg(state->dev, "arm: vchiq open\n");
 
-	if (!state) {
-		dev_err(state->dev, "arm: vchiq has no connection to VideoCore\n");
-		return -ENOTCONN;
-	}
-
 	instance = kzalloc(sizeof(*instance), GFP_KERNEL);
 	if (!instance)
 		return -ENOMEM;
-- 
2.43.0
Re: [PATCH] staging: vc04_services: Delete unnecessary NULL check
Posted by Umang Jain 1 year, 9 months ago
HI Dan,

Thank you for the patch

On 24/04/24 5:13 pm, Dan Carpenter wrote:
> The "state" pointer points to an offset in the middle of the "mgmt"
> struct so it can't possibly be NULL.  And also we dereferenced it on the
> line before.  So this NULL check is pointless.  Delete it.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>

Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
> ---
>   .../staging/vc04_services/interface/vchiq_arm/vchiq_dev.c    | 5 -----
>   1 file changed, 5 deletions(-)
>
> diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c
> index 9fe35864936c..3c63347d2d08 100644
> --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c
> +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c
> @@ -1170,11 +1170,6 @@ static int vchiq_open(struct inode *inode, struct file *file)
>   
>   	dev_dbg(state->dev, "arm: vchiq open\n");
>   
> -	if (!state) {
> -		dev_err(state->dev, "arm: vchiq has no connection to VideoCore\n");
> -		return -ENOTCONN;
> -	}
> -
>   	instance = kzalloc(sizeof(*instance), GFP_KERNEL);
>   	if (!instance)
>   		return -ENOMEM;
Re: [PATCH] staging: vc04_services: Delete unnecessary NULL check
Posted by Stefan Wahren 1 year, 9 months ago
Am 24.04.24 um 13:43 schrieb Dan Carpenter:
> The "state" pointer points to an offset in the middle of the "mgmt"
> struct so it can't possibly be NULL.  And also we dereferenced it on the
> line before.  So this NULL check is pointless.  Delete it.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Stefan Wahren <wahrenst@gmx.net>

Thanks