Skip to content

Commit

Permalink
crypto: picoxcell - Fix potential race condition bug
Browse files Browse the repository at this point in the history
[ Upstream commit 64f4a62 ]

engine->stat_irq_thresh was initialized after device_create_file() in
the probe function, the initialization may race with call to
spacc_stat_irq_thresh_store() which updates engine->stat_irq_thresh,
therefore initialize it before creating the file in probe function.

Found by Linux Driver Verification project (linuxtesting.org).

Fixes: ce92136 ("crypto: picoxcell - add support for the...")
Signed-off-by: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
Acked-by: Jamie Iles <jamie@jamieiles.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Madhuparna Bhowmik authored and gregkh committed Oct 29, 2020
1 parent 5ec044f commit 0ebbe42
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions drivers/crypto/picoxcell_crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -1666,18 +1666,17 @@ static int spacc_probe(struct platform_device *pdev)
goto err_clk_put;
}

ret = device_create_file(&pdev->dev, &dev_attr_stat_irq_thresh);
if (ret)
goto err_clk_disable;


/*
* Use an IRQ threshold of 50% as a default. This seems to be a
* reasonable trade off of latency against throughput but can be
* changed at runtime.
*/
engine->stat_irq_thresh = (engine->fifo_sz / 2);

ret = device_create_file(&pdev->dev, &dev_attr_stat_irq_thresh);
if (ret)
goto err_clk_disable;

/*
* Configure the interrupts. We only use the STAT_CNT interrupt as we
* only submit a new packet for processing when we complete another in
Expand Down

0 comments on commit 0ebbe42

Please sign in to comment.