mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tero Kristo <t-kristo@ti.com>
To: Colin King <colin.king@canonical.com>,
	Michael Turquette <mturquette@baylibre.com>,
	Stephen Boyd <sboyd@codeaurora.org>, <linux-omap@vger.kernel.org>,
	<linux-clk@vger.kernel.org>
Cc: <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH][next] clk: ti: check for null return in strrchr to avoid null dereferencing
Date: Thu, 27 Jul 2017 09:05:13 +0300	[thread overview]
Message-ID: <a39a4ba7-809d-a4af-6547-473978749451@ti.com> (raw)
In-Reply-To: <20170726235627.9163-1-colin.king@canonical.com>

On 27/07/17 02:56, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> strrchr can potentially return a null so the following strlen on the
> null pointer can cause a null dereference. Add a check to see if
> the string postfix is not null before calling strlen.
> 
> Detected by CoverityScan, CID#1452039 ("Dereference null return")
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   drivers/clk/ti/adpll.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/clk/ti/adpll.c b/drivers/clk/ti/adpll.c
> index 255cafb18336..bd7cb9a413c9 100644
> --- a/drivers/clk/ti/adpll.c
> +++ b/drivers/clk/ti/adpll.c
> @@ -222,7 +222,7 @@ static int ti_adpll_setup_clock(struct ti_adpll_data *d, struct clk *clock,
>   
>   	/* Separate con_id in format "pll040dcoclkldo" to fit MAX_CON_ID */
>   	postfix = strrchr(name, '.');
> -	if (strlen(postfix) > 1) {
> +	if (postfix && strlen(postfix) > 1) {
>   		if (strlen(postfix) > ADPLL_MAX_CON_ID)
>   			dev_warn(d->dev, "clock %s con_id lookup may fail\n",
>   				 name);
> 

Looks fine to me.

Acked-by: Tero Kristo <t-kristo@ti.com>

  reply	other threads:[~2017-07-27  6:05 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-26 23:56 Colin King
2017-07-27  6:05 ` Tero Kristo [this message]
2017-09-01  1:45 ` Stephen Boyd

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=a39a4ba7-809d-a4af-6547-473978749451@ti.com \
    --to=t-kristo@ti.com \
    --cc=colin.king@canonical.com \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=sboyd@codeaurora.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

all inboxes | Powered by JetHome®