mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] vlynq : Handle return value of platform_get_irq_byname and vlynq_probe
@ 2017-11-17 16:21 Arvind Yadav
  2017-11-17 16:49 ` Florian Fainelli
  0 siblings, 1 reply; 2+ messages in thread
From: Arvind Yadav @ 2017-11-17 16:21 UTC (permalink / raw)
  To: f.fainelli; +Cc: linux-kernel

platform_get_irq_byname() can fail here and we must check its return value.

device_register() can fail here, initialised 'result' variable
beforen'goto fail_register' otherwise vlynq_probe will return uninitialised
'result' variable.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
---
 drivers/vlynq/vlynq.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/vlynq/vlynq.c b/drivers/vlynq/vlynq.c
index c0227f9..bc735f9 100644
--- a/drivers/vlynq/vlynq.c
+++ b/drivers/vlynq/vlynq.c
@@ -722,13 +722,19 @@ static int vlynq_probe(struct platform_device *pdev)
 					    VLYNQ_REMOTE_OFFSET);
 
 	dev->irq = platform_get_irq_byname(pdev, "irq");
+	if (dev->irq < 0) {
+		result = dev->irq;
+		goto fail_register;
+	}
 	dev->irq_start = irq_res->start;
 	dev->irq_end = irq_res->end;
 	dev->local_irq = dev->irq_end - dev->irq_start;
 	dev->remote_irq = dev->local_irq - 1;
 
-	if (device_register(&dev->dev))
+	if (device_register(&dev->dev)) {
+		result = -ENXIO;
 		goto fail_register;
+	}
 	platform_set_drvdata(pdev, dev);
 
 	printk(KERN_INFO "%s: regs 0x%p, irq %d, mem 0x%p\n",
-- 
2.7.4

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-11-17 16:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-17 16:21 [PATCH] vlynq : Handle return value of platform_get_irq_byname and vlynq_probe Arvind Yadav
2017-11-17 16:49 ` Florian Fainelli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®