Skip to content

Commit

Permalink
clk: ti: check for null return in strrchr to avoid null dereferencing
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Colin Ian King authored and Stephen Boyd committed Sep 1, 2017
1 parent 2316a7a commit df2f845
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/clk/ti/adpll.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit df2f845

Please sign in to comment.