diff mbox

fpga: fpga-bridge: remove unnecessary null check in of_fpga_bridge_get

Message ID 20171027201951.GA27077@embeddedor.com (mailing list archive)
State Accepted, archived
Headers show

Commit Message

Gustavo A. R. Silva Oct. 27, 2017, 8:19 p.m. UTC
Notice that bridge = to_fpga_bridge(dev); expands to:

bridge = container_of(dev, struct fpga_bridge, dev);

and container_of is never null, so this null check is
unnecessary.

Addresses-Coverity-ID: 1397912
Reported-by: Alan Tull <atull@kernel.org>
Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
---
 drivers/fpga/fpga-bridge.c | 2 --
 1 file changed, 2 deletions(-)

Comments

Moritz Fischer Oct. 28, 2017, 5:15 p.m. UTC | #1
On Fri, Oct 27, 2017 at 08:19:51PM +0000, Gustavo A. R. Silva wrote:
> Notice that bridge = to_fpga_bridge(dev); expands to:
> 
> bridge = container_of(dev, struct fpga_bridge, dev);
> 
> and container_of is never null, so this null check is
> unnecessary.
> 
> Addresses-Coverity-ID: 1397912
> Reported-by: Alan Tull <atull@kernel.org>
> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
Reviewed-by: Moritz Fischer <mdf@kernel.org>
> ---
>  drivers/fpga/fpga-bridge.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/drivers/fpga/fpga-bridge.c b/drivers/fpga/fpga-bridge.c
> index 9651aa5..409d1ac 100644
> --- a/drivers/fpga/fpga-bridge.c
> +++ b/drivers/fpga/fpga-bridge.c
> @@ -94,8 +94,6 @@ struct fpga_bridge *of_fpga_bridge_get(struct device_node *np,
>  		goto err_dev;
>  
>  	bridge = to_fpga_bridge(dev);
> -	if (!bridge)
> -		goto err_dev;
>  
>  	bridge->info = info;
>  
> -- 
> 2.7.4
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-fpga" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

Thanks for the fix,

Moritz
--
To unsubscribe from this list: send the line "unsubscribe linux-fpga" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Gustavo A. R. Silva Oct. 29, 2017, 12:25 a.m. UTC | #2
Hi Moritz,

Quoting Moritz Fischer <mdf@kernel.org>:

> On Fri, Oct 27, 2017 at 08:19:51PM +0000, Gustavo A. R. Silva wrote:
>> Notice that bridge = to_fpga_bridge(dev); expands to:
>>
>> bridge = container_of(dev, struct fpga_bridge, dev);
>>
>> and container_of is never null, so this null check is
>> unnecessary.
>>
>> Addresses-Coverity-ID: 1397912
>> Reported-by: Alan Tull <atull@kernel.org>
>> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
> Reviewed-by: Moritz Fischer <mdf@kernel.org>
>> ---
>>  drivers/fpga/fpga-bridge.c | 2 --
>>  1 file changed, 2 deletions(-)
>>
>> diff --git a/drivers/fpga/fpga-bridge.c b/drivers/fpga/fpga-bridge.c
>> index 9651aa5..409d1ac 100644
>> --- a/drivers/fpga/fpga-bridge.c
>> +++ b/drivers/fpga/fpga-bridge.c
>> @@ -94,8 +94,6 @@ struct fpga_bridge *of_fpga_bridge_get(struct  
>> device_node *np,
>>  		goto err_dev;
>>
>>  	bridge = to_fpga_bridge(dev);
>> -	if (!bridge)
>> -		goto err_dev;
>>
>>  	bridge->info = info;
>>
>> --
>> 2.7.4
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-fpga" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
> Thanks for the fix,
>

Glad to help.

Thanks
--
Gustavo A. R. Silva






--
To unsubscribe from this list: send the line "unsubscribe linux-fpga" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Alan Tull Oct. 30, 2017, 8:34 p.m. UTC | #3
On Sat, Oct 28, 2017 at 12:15 PM, Moritz Fischer <mdf@kernel.org> wrote:

Hi Gustavo,

Thanks!

Alan

> On Fri, Oct 27, 2017 at 08:19:51PM +0000, Gustavo A. R. Silva wrote:
>> Notice that bridge = to_fpga_bridge(dev); expands to:
>>
>> bridge = container_of(dev, struct fpga_bridge, dev);
>>
>> and container_of is never null, so this null check is
>> unnecessary.
>>
>> Addresses-Coverity-ID: 1397912
>> Reported-by: Alan Tull <atull@kernel.org>
>> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
> Reviewed-by: Moritz Fischer <mdf@kernel.org>

Signed-off-by: Alan Tull <atull@kernel.org>

>> ---
>>  drivers/fpga/fpga-bridge.c | 2 --
>>  1 file changed, 2 deletions(-)
>>
>> diff --git a/drivers/fpga/fpga-bridge.c b/drivers/fpga/fpga-bridge.c
>> index 9651aa5..409d1ac 100644
>> --- a/drivers/fpga/fpga-bridge.c
>> +++ b/drivers/fpga/fpga-bridge.c
>> @@ -94,8 +94,6 @@ struct fpga_bridge *of_fpga_bridge_get(struct device_node *np,
>>               goto err_dev;
>>
>>       bridge = to_fpga_bridge(dev);
>> -     if (!bridge)
>> -             goto err_dev;
>>
>>       bridge->info = info;
>>
>> --
>> 2.7.4
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-fpga" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
> Thanks for the fix,
>
> Moritz
--
To unsubscribe from this list: send the line "unsubscribe linux-fpga" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Gustavo A. R. Silva Oct. 30, 2017, 10:20 p.m. UTC | #4
Hi Alan,

Quoting Alan Tull <atull@kernel.org>:

> On Sat, Oct 28, 2017 at 12:15 PM, Moritz Fischer <mdf@kernel.org> wrote:
>
> Hi Gustavo,
>
> Thanks!
>

Glad to help. :)

Thanks
--
Gustavo A. R. Silva






--
To unsubscribe from this list: send the line "unsubscribe linux-fpga" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/fpga/fpga-bridge.c b/drivers/fpga/fpga-bridge.c
index 9651aa5..409d1ac 100644
--- a/drivers/fpga/fpga-bridge.c
+++ b/drivers/fpga/fpga-bridge.c
@@ -94,8 +94,6 @@  struct fpga_bridge *of_fpga_bridge_get(struct device_node *np,
 		goto err_dev;
 
 	bridge = to_fpga_bridge(dev);
-	if (!bridge)
-		goto err_dev;
 
 	bridge->info = info;