mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ti-msgmgr: fix of_irq_get_byname() error check
@ 2017-07-29 21:04 Sergei Shtylyov
  2017-07-29 21:08 ` Sergei Shtylyov
  2017-07-29 21:12 ` Sergei Shtylyov
  0 siblings, 2 replies; 3+ messages in thread
From: Sergei Shtylyov @ 2017-07-29 21:04 UTC (permalink / raw)
  To: Jassi Brar, linux-kernel; +Cc: Sergei Shtylyov

[-- Attachment #1: ti-msgmgr-fix-of_irq_get_byname-error-check.patch --]
[-- Type: text/plain, Size: 1312 bytes --]

of_irq_get_byname() may  return 0 as well as negative error number on
failure,  while the driver only checks for the negative values. The driver
would then call request_irq(0, ...) in ti_msgmgr_queue_startup() and never
get a valid channel interrupt.

Check for 'qinst->irq <= 0' instead and return -ENXIO from
ti_msgmgr_queue_setup() and this fail the driver's probe iff
of_irq_get_byname() returned 0.

Fixes: aace66b170ce ("mailbox: Introduce TI message manager driver")
Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>

---
 drivers/mailbox/ti-msgmgr.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Index: linux/drivers/mailbox/ti-msgmgr.c
===================================================================
--- linux.orig/drivers/mailbox/ti-msgmgr.c
+++ linux/drivers/mailbox/ti-msgmgr.c
@@ -444,12 +444,12 @@ static int ti_msgmgr_queue_setup(int idx
 			 "rx_%03d", qinst->queue_id);
 
 		qinst->irq = of_irq_get_byname(np, of_rx_irq_name);
-		if (qinst->irq < 0) {
+		if (qinst->irq <= 0) {
 			dev_crit(dev,
 				 "[%d]QID %d PID %d:No IRQ[%s]: %d\n",
 				 idx, qinst->queue_id, qinst->proxy_id,
 				 of_rx_irq_name, qinst->irq);
-			return qinst->irq;
+			return qinst->irq ?: -ENXIO;
 		}
 		/* Allocate usage buffer for rx */
 		qinst->rx_buff = devm_kzalloc(dev,

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

end of thread, other threads:[~2017-07-29 21:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-29 21:04 [PATCH] ti-msgmgr: fix of_irq_get_byname() error check Sergei Shtylyov
2017-07-29 21:08 ` Sergei Shtylyov
2017-07-29 21:12 ` Sergei Shtylyov

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®