linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: zhangyue <zhangyue1@kylinos.cn>, wim@linux-watchdog.org
Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] watchdog: fix array may be out of bound
Date: Sun, 12 Dec 2021 20:03:33 -0800	[thread overview]
Message-ID: <8cef5d56-0d26-d35c-13c4-f6a6671888a2@roeck-us.net> (raw)
In-Reply-To: <20211213033419.70458-1-zhangyue1@kylinos.cn>

On 12/12/21 7:34 PM, zhangyue wrote:
> In this function, the param 'idx' may be
> equal to 'DW_WDT_NUM_TOPS'.
> At this time, the array 'dw_wdt->timeouts'
> may be out of bound
> 
> Signed-off-by: zhangyue <zhangyue1@kylinos.cn>
> ---
>   drivers/watchdog/dw_wdt.c | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/watchdog/dw_wdt.c b/drivers/watchdog/dw_wdt.c
> index cd578843277e..15fb1895c085 100644
> --- a/drivers/watchdog/dw_wdt.c
> +++ b/drivers/watchdog/dw_wdt.c
> @@ -155,6 +155,9 @@ static unsigned int dw_wdt_get_min_timeout(struct dw_wdt *dw_wdt)
>   			break;
>   	}
>   
> +	if (idx == DW_WDT_NUM_TOPS)
> +		return 1;
> +

Please look at the code (and the comments) more closely.
This can not happen.

Guenter

      reply	other threads:[~2021-12-13  4:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-13  3:34 [PATCH] watchdog: fix array may be out of bound zhangyue
2021-12-13  4:03 ` Guenter Roeck [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=8cef5d56-0d26-d35c-13c4-f6a6671888a2@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=wim@linux-watchdog.org \
    --cc=zhangyue1@kylinos.cn \
    /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).