linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Fabien DESSENNE <fabien.dessenne@st.com>
To: Jia-Ju Bai <baijiaju1990@gmail.com>,
	"mchehab@kernel.org" <mchehab@kernel.org>
Cc: "linux-media@vger.kernel.org" <linux-media@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] media: sti: bdisp: fix a possible sleep-in-atomic-context bug in bdisp_device_run()
Date: Thu, 19 Dec 2019 11:14:26 +0000	[thread overview]
Message-ID: <b4be57d4-4f9a-ff4a-6fce-35b5f48570cb@st.com> (raw)
In-Reply-To: <20191219103401.13630-1-baijiaju1990@gmail.com>

Thank you!


On 19/12/2019 11:34 AM, Jia-Ju Bai wrote:
> The driver may sleep while holding a spinlock.
> The function call path (from bottom to top) in Linux 4.19 is:
>
> drivers/media/platform/sti/bdisp/bdisp-hw.c, 385:
>      msleep in bdisp_hw_reset
> drivers/media/platform/sti/bdisp/bdisp-v4l2.c, 341:
>      bdisp_hw_reset in bdisp_device_run
> drivers/media/platform/sti/bdisp/bdisp-v4l2.c, 317:
>      _raw_spin_lock_irqsave in bdisp_device_run
>
> To fix this bug, msleep() is replaced with udelay().
>
> This bug is found by a static analysis tool STCheck written by myself.
>
> Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>


Reviewed-by: Fabien Dessenne <fabien.dessenne@st.com>


> ---
> v2:
> * Use udelay() instead of mdelay().
>    Thank Fabien for good advice.
>
> ---
>   drivers/media/platform/sti/bdisp/bdisp-hw.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/media/platform/sti/bdisp/bdisp-hw.c b/drivers/media/platform/sti/bdisp/bdisp-hw.c
> index 4372abbb5950..a74e9fd65238 100644
> --- a/drivers/media/platform/sti/bdisp/bdisp-hw.c
> +++ b/drivers/media/platform/sti/bdisp/bdisp-hw.c
> @@ -14,8 +14,8 @@
>   #define MAX_SRC_WIDTH           2048
>   
>   /* Reset & boot poll config */
> -#define POLL_RST_MAX            50
> -#define POLL_RST_DELAY_MS       20
> +#define POLL_RST_MAX            500
> +#define POLL_RST_DELAY_MS       2
>   
>   enum bdisp_target_plan {
>   	BDISP_RGB,
> @@ -382,7 +382,7 @@ int bdisp_hw_reset(struct bdisp_dev *bdisp)
>   	for (i = 0; i < POLL_RST_MAX; i++) {
>   		if (readl(bdisp->regs + BLT_STA1) & BLT_STA1_IDLE)
>   			break;
> -		msleep(POLL_RST_DELAY_MS);
> +		udelay(POLL_RST_DELAY_MS * 1000);
>   	}
>   	if (i == POLL_RST_MAX)
>   		dev_err(bdisp->dev, "Reset timeout\n");

      reply	other threads:[~2019-12-19 11:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-19 10:34 [PATCH v2] media: sti: bdisp: fix a possible sleep-in-atomic-context bug in bdisp_device_run() Jia-Ju Bai
2019-12-19 11:14 ` Fabien DESSENNE [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b4be57d4-4f9a-ff4a-6fce-35b5f48570cb@st.com \
    --to=fabien.dessenne@st.com \
    --cc=baijiaju1990@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).