From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933537AbdCUQ6F (ORCPT ); Tue, 21 Mar 2017 12:58:05 -0400 Received: from foss.arm.com ([217.140.101.70]:56194 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757195AbdCUQ5o (ORCPT ); Tue, 21 Mar 2017 12:57:44 -0400 From: Alexey Klimov To: jassisinghbrar@gmail.com, linux-kernel@vger.kernel.org Cc: sudeep.holla@arm.com, jaswinder.singh@linaro.org Subject: [PATCH] mailbox: check ->last_tx_done for NULL in case of timer-based polling Date: Tue, 21 Mar 2017 16:57:34 +0000 Message-Id: <1490115454-32308-1-git-send-email-alexey.klimov@arm.com> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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