[linux-yocto] [PATCH 7/9] char: hwrng: don't use static pointer to driver data as it goes to .bss

Daniel Dragomir daniel.dragomir at windriver.com
Thu Mar 9 08:22:28 PST 2017


From: Marek Bykowski <marek.bykowski at gmail.com>

Also do not pass a pointer to the pointer allocated in the stack to
the function as effectively you pass the address from the stack
frame which is nowhere after the frame returns.

Signed-off-by: Marek Bykowski <marek.bykowski at gmail.com>
---
 drivers/char/hw_random/axxia-rng.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/char/hw_random/axxia-rng.c b/drivers/char/hw_random/axxia-rng.c
index 7790493..42b1ba3 100644
--- a/drivers/char/hw_random/axxia-rng.c
+++ b/drivers/char/hw_random/axxia-rng.c
@@ -452,7 +452,7 @@ static DRIVER_ATTR(trng_test_mode, S_IRUGO | S_IWUSR,
  */
 static int trng_probe(struct platform_device *pdev)
 {
-	static struct trng_dev *dev;
+	struct trng_dev *dev;
 	void __iomem *regs;
 	int rc;
 	u32 *pregs;
@@ -464,7 +464,7 @@ static int trng_probe(struct platform_device *pdev)
 		rc = -ENOMEM;
 		goto err;
 	}
-	dev_set_drvdata(&pdev->dev, &dev);
+	dev_set_drvdata(&pdev->dev, dev);
 	kref_init(&dev->ref);
 	dev->pdev = pdev;
 
@@ -483,7 +483,7 @@ static int trng_probe(struct platform_device *pdev)
 #endif
 	/* Attach to IRQ */
 	dev->irq = irq_of_parse_and_map(pdev->dev.of_node, 0);
-	rc = request_irq(dev->irq, trng_isr, 0, "trng", &dev);
+	rc = request_irq(dev->irq, trng_isr, 0, "trng", dev);
 	if (rc)
 		goto err;
 
@@ -546,7 +546,7 @@ static void trng_destroy(struct kref *ref)
 	if (test_and_clear_bit(FLAG_REGISTERED, &dev->flags))
 		hwrng_unregister(&dev->rng_dev);
 	if (dev->irq)
-		free_irq(dev->irq, &dev);
+		free_irq(dev->irq, dev);
 	iounmap(dev->regs);
 	kfree(dev);
 }
-- 
2.7.4



More information about the linux-yocto mailing list