linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mailbox: check ->last_tx_done for NULL in case of timer-based polling
@ 2017-03-21 16:57 Alexey Klimov
  2017-03-21 17:03 ` Sudeep Holla
  0 siblings, 1 reply; 2+ messages in thread
From: Alexey Klimov @ 2017-03-21 16:57 UTC (permalink / raw)
  To: jassisinghbrar, linux-kernel; +Cc: sudeep.holla, jaswinder.singh

It is allowed by code to register mailbox controller that sets txdone_poll
flag to request timer-based polling with missed ->last_tx_done() method.
If such thing happens and since presence of last_tx_done() is not checked
it will fail in hrtimer callback function txdone_hrtimer() when first
message will be transmitted.

This patch adds check for this method and logging of error on
registration of mailbox controller if it requested timer-based polling.

Signed-off-by: Alexey Klimov <alexey.klimov@arm.com>
---
 drivers/mailbox/mailbox.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c
index 4671f8a..59b7221 100644
--- a/drivers/mailbox/mailbox.c
+++ b/drivers/mailbox/mailbox.c
@@ -453,6 +453,12 @@ int mbox_controller_register(struct mbox_controller *mbox)
 		txdone = TXDONE_BY_ACK;
 
 	if (txdone == TXDONE_BY_POLL) {
+
+		if (!mbox->ops->last_tx_done) {
+			dev_err(mbox->dev, "last_tx_done method is absent\n");
+			return -EINVAL;
+		}
+
 		hrtimer_init(&mbox->poll_hrt, CLOCK_MONOTONIC,
 			     HRTIMER_MODE_REL);
 		mbox->poll_hrt.function = txdone_hrtimer;
-- 
1.9.1

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

* Re: [PATCH] mailbox: check ->last_tx_done for NULL in case of timer-based polling
  2017-03-21 16:57 [PATCH] mailbox: check ->last_tx_done for NULL in case of timer-based polling Alexey Klimov
@ 2017-03-21 17:03 ` Sudeep Holla
  0 siblings, 0 replies; 2+ messages in thread
From: Sudeep Holla @ 2017-03-21 17:03 UTC (permalink / raw)
  To: Alexey Klimov, jassisinghbrar, linux-kernel; +Cc: Sudeep Holla, jaswinder.singh



On 21/03/17 16:57, Alexey Klimov wrote:
> It is allowed by code to register mailbox controller that sets txdone_poll
> flag to request timer-based polling with missed ->last_tx_done() method.
> If such thing happens and since presence of last_tx_done() is not checked
> it will fail in hrtimer callback function txdone_hrtimer() when first
> message will be transmitted.
> 
> This patch adds check for this method and logging of error on
> registration of mailbox controller if it requested timer-based polling.
> 

Good to have check.

Acked-by: Sudeep Holla <sudeep.holla@arm.com>

-- 
Regards,
Sudeep

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

end of thread, other threads:[~2017-03-21 17:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-21 16:57 [PATCH] mailbox: check ->last_tx_done for NULL in case of timer-based polling Alexey Klimov
2017-03-21 17:03 ` Sudeep Holla

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).