aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColin Ian King <colin.king@canonical.com>2017-07-26 19:56:27 -0400
committerStephen Boyd <sboyd@codeaurora.org>2017-08-31 21:44:13 -0400
commitdf2f84516758788889281e97d736c7863ff200ea (patch)
tree36758c824f6a6720282a6c2717c5495c612f6313
parent2316a7a33408b6e7b24e9d2a9a7c24af9a012289 (diff)
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 <colin.king@canonical.com> Acked-by: Tero Kristo <t-kristo@ti.com> Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
-rw-r--r--drivers/clk/ti/adpll.c2
1 files changed, 1 insertions, 1 deletions
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,
222 222
223 /* Separate con_id in format "pll040dcoclkldo" to fit MAX_CON_ID */ 223 /* Separate con_id in format "pll040dcoclkldo" to fit MAX_CON_ID */
224 postfix = strrchr(name, '.'); 224 postfix = strrchr(name, '.');
225 if (strlen(postfix) > 1) { 225 if (postfix && strlen(postfix) > 1) {
226 if (strlen(postfix) > ADPLL_MAX_CON_ID) 226 if (strlen(postfix) > ADPLL_MAX_CON_ID)
227 dev_warn(d->dev, "clock %s con_id lookup may fail\n", 227 dev_warn(d->dev, "clock %s con_id lookup may fail\n",
228 name); 228 name);