All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anna-Maria Behnsen <anna-maria@linutronix.de>
To: Phil Chang <phil.chang@mediatek.com>
Cc: alix.wu@mediatek.com, angelogioacchino.delregno@collabora.com,
	frederic@kernel.org, jy.ho@mediatek.com,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, matthias.bgg@gmail.com,
	phil.chang@mediatek.com, tglx@linutronix.de
Subject: Re: [PATCH v2] hrtimer: check hrtimer with a NULL function
Date: Mon, 10 Jun 2024 11:47:40 +0200	[thread overview]
Message-ID: <87bk496seb.fsf@somnus> (raw)
In-Reply-To: <20240607022614.22902-1-phil.chang@mediatek.com>

Phil Chang <phil.chang@mediatek.com> writes:

> Since hrtimers do not allow a NULL function to be passed,
> to prevent a kernel crash, return before adding the timer to a queue.

You could point out in the commit message, where the kernel would crash
when using a hrtimer with a NULL pointer as function pointer. And it
shouldn't be a problem to use more than a single sentence for a commit
message :)

> Signed-off-by: Phil Chang <phil.chang@mediatek.com>
> ---
>  kernel/time/hrtimer.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
> index 492c14aac642..d32c1afe59b3 100644
> --- a/kernel/time/hrtimer.c
> +++ b/kernel/time/hrtimer.c
> @@ -1285,6 +1285,9 @@ void hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim,
>  	struct hrtimer_clock_base *base;
>  	unsigned long flags;
>  
> +	if (WARN_ON(!timer->function))
> +		return;
> +

Please use a WARN_ON_ONCE() (as documented in
Documentation/process/coding-style.rst)

>  	/*
>  	 * Check whether the HRTIMER_MODE_SOFT bit and hrtimer.is_soft
>  	 * match on CONFIG_PREEMPT_RT = n. With PREEMPT_RT check the hard

Thanks,

	Anna-Maria


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

WARNING: multiple messages have this Message-ID (diff)
From: Anna-Maria Behnsen <anna-maria@linutronix.de>
To: Phil Chang <phil.chang@mediatek.com>
Cc: alix.wu@mediatek.com, angelogioacchino.delregno@collabora.com,
	frederic@kernel.org, jy.ho@mediatek.com,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, matthias.bgg@gmail.com,
	phil.chang@mediatek.com, tglx@linutronix.de
Subject: Re: [PATCH v2] hrtimer: check hrtimer with a NULL function
Date: Mon, 10 Jun 2024 11:47:40 +0200	[thread overview]
Message-ID: <87bk496seb.fsf@somnus> (raw)
In-Reply-To: <20240607022614.22902-1-phil.chang@mediatek.com>

Phil Chang <phil.chang@mediatek.com> writes:

> Since hrtimers do not allow a NULL function to be passed,
> to prevent a kernel crash, return before adding the timer to a queue.

You could point out in the commit message, where the kernel would crash
when using a hrtimer with a NULL pointer as function pointer. And it
shouldn't be a problem to use more than a single sentence for a commit
message :)

> Signed-off-by: Phil Chang <phil.chang@mediatek.com>
> ---
>  kernel/time/hrtimer.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
> index 492c14aac642..d32c1afe59b3 100644
> --- a/kernel/time/hrtimer.c
> +++ b/kernel/time/hrtimer.c
> @@ -1285,6 +1285,9 @@ void hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim,
>  	struct hrtimer_clock_base *base;
>  	unsigned long flags;
>  
> +	if (WARN_ON(!timer->function))
> +		return;
> +

Please use a WARN_ON_ONCE() (as documented in
Documentation/process/coding-style.rst)

>  	/*
>  	 * Check whether the HRTIMER_MODE_SOFT bit and hrtimer.is_soft
>  	 * match on CONFIG_PREEMPT_RT = n. With PREEMPT_RT check the hard

Thanks,

	Anna-Maria


  reply	other threads:[~2024-06-10  9:48 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-05  8:41 [PATCH] hrtimer: check hrtimer with a NULL function Phil Chang
2024-06-05  8:41 ` Phil Chang
2024-06-05 10:15 ` Anna-Maria Behnsen
2024-06-05 10:15   ` Anna-Maria Behnsen
2024-06-05 13:51   ` Phil Chang
2024-06-05 13:51     ` Phil Chang
2024-06-06 13:14     ` Anna-Maria Behnsen
2024-06-06 13:14       ` Anna-Maria Behnsen
2024-06-07  2:26       ` [PATCH v2] " Phil Chang
2024-06-07  2:26         ` Phil Chang
2024-06-10  9:47         ` Anna-Maria Behnsen [this message]
2024-06-10  9:47           ` Anna-Maria Behnsen
2024-06-10 13:31           ` [PATCH v3] " Phil Chang
2024-06-10 13:31             ` Phil Chang
2024-06-17 16:19             ` Anna-Maria Behnsen

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=87bk496seb.fsf@somnus \
    --to=anna-maria@linutronix.de \
    --cc=alix.wu@mediatek.com \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=frederic@kernel.org \
    --cc=jy.ho@mediatek.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matthias.bgg@gmail.com \
    --cc=phil.chang@mediatek.com \
    --cc=tglx@linutronix.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.