From: Colin Ian King Date: Wed, 26 Jul 2017 23:56:27 +0000 (+0100) Subject: clk: ti: check for null return in strrchr to avoid null dereferencing X-Git-Tag: v4.14-rc1~38^2~9 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=df2f84516758788889281e97d736c7863ff200ea;p=linux-block.git clk: ti: check for null return in strrchr to avoid null dereferencing 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 Acked-by: Tero Kristo Signed-off-by: Stephen Boyd --- diff --git a/drivers/clk/ti/adpll.c b/drivers/clk/ti/adpll.c index d5c6db446316..d6036c788fab 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);