firmware: tegra: adjust tested variable

Message ID 1517063308-16679-1-git-send-email-Julia.Lawall@lip6.fr
State Accepted
Headers show
Series
  • firmware: tegra: adjust tested variable
Related show

Commit Message

Julia Lawall Jan. 27, 2018, 2:28 p.m.
Check the variable that was most recently initialized.

The semantic match that finds this problem is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
expression x, y, f, g, e, m;
statement S1,S2,S3,S4;
@@

x = f(...);
if (\(<+...x...+>\&e\)) S1 else S2
(
x = g(...);
|
m = g(...,&x,...);
|
y = g(...);
*if (e)
 S3 else S4
)
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 drivers/firmware/tegra/bpmp.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


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

Comments

Mikko Perttunen Jan. 27, 2018, 3:03 p.m. | #1
Reviewed-by: Mikko Perttunen <mperttunen@nvidia.com>

On 01/27/2018 04:28 PM, Julia Lawall wrote:
> Check the variable that was most recently initialized.
> 
> The semantic match that finds this problem is as follows:
> (http://coccinelle.lip6.fr/)
> 
> // <smpl>
> @@
> expression x, y, f, g, e, m;
> statement S1,S2,S3,S4;
> @@
> 
> x = f(...);
> if (\(<+...x...+>\&e\)) S1 else S2
> (
> x = g(...);
> |
> m = g(...,&x,...);
> |
> y = g(...);
> *if (e)
>   S3 else S4
> )
> // </smpl>
> 
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
> 
> ---
>   drivers/firmware/tegra/bpmp.c |    2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/firmware/tegra/bpmp.c b/drivers/firmware/tegra/bpmp.c
> index a7f461f..96362b5 100644
> --- a/drivers/firmware/tegra/bpmp.c
> +++ b/drivers/firmware/tegra/bpmp.c
> @@ -732,7 +732,7 @@ static int tegra_bpmp_probe(struct platform_device *pdev)
>   	}
>   
>   	bpmp->rx.virt = gen_pool_dma_alloc(bpmp->rx.pool, 4096, &bpmp->rx.phys);
> -	if (!bpmp->rx.pool) {
> +	if (!bpmp->rx.virt) {
>   		dev_err(&pdev->dev, "failed to allocate from RX pool\n");
>   		err = -ENOMEM;
>   		goto free_tx;
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-tegra" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-tegra" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Thierry Reding March 8, 2018, 1:43 p.m. | #2
On Sat, Jan 27, 2018 at 03:28:28PM +0100, Julia Lawall wrote:
> Check the variable that was most recently initialized.
> 
> The semantic match that finds this problem is as follows:
> (http://coccinelle.lip6.fr/)
> 
> // <smpl>
> @@
> expression x, y, f, g, e, m;
> statement S1,S2,S3,S4;
> @@
> 
> x = f(...);
> if (\(<+...x...+>\&e\)) S1 else S2
> (
> x = g(...);
> |
> m = g(...,&x,...);
> |
> y = g(...);
> *if (e)
>  S3 else S4
> )
> // </smpl>
> 
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
> 
> ---
>  drivers/firmware/tegra/bpmp.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Applied, thanks.

Thierry

Patch

diff --git a/drivers/firmware/tegra/bpmp.c b/drivers/firmware/tegra/bpmp.c
index a7f461f..96362b5 100644
--- a/drivers/firmware/tegra/bpmp.c
+++ b/drivers/firmware/tegra/bpmp.c
@@ -732,7 +732,7 @@  static int tegra_bpmp_probe(struct platform_device *pdev)
 	}
 
 	bpmp->rx.virt = gen_pool_dma_alloc(bpmp->rx.pool, 4096, &bpmp->rx.phys);
-	if (!bpmp->rx.pool) {
+	if (!bpmp->rx.virt) {
 		dev_err(&pdev->dev, "failed to allocate from RX pool\n");
 		err = -ENOMEM;
 		goto free_tx;