* [PATCH][next] clk: ti: check for null return in strrchr to avoid null dereferencing
@ 2017-07-26 23:56 Colin King
2017-07-27 6:05 ` Tero Kristo
2017-09-01 1:45 ` Stephen Boyd
0 siblings, 2 replies; 3+ messages in thread
From: Colin King @ 2017-07-26 23:56 UTC (permalink / raw)
To: Tero Kristo, Michael Turquette, Stephen Boyd, linux-omap,
linux-clk
Cc: linux-kernel
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);
--
2.11.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH][next] clk: ti: check for null return in strrchr to avoid null dereferencing
2017-07-26 23:56 [PATCH][next] clk: ti: check for null return in strrchr to avoid null dereferencing Colin King
@ 2017-07-27 6:05 ` Tero Kristo
2017-09-01 1:45 ` Stephen Boyd
1 sibling, 0 replies; 3+ messages in thread
From: Tero Kristo @ 2017-07-27 6:05 UTC (permalink / raw)
To: Colin King, Michael Turquette, Stephen Boyd, linux-omap,
linux-clk
Cc: linux-kernel
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>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH][next] clk: ti: check for null return in strrchr to avoid null dereferencing
2017-07-26 23:56 [PATCH][next] clk: ti: check for null return in strrchr to avoid null dereferencing Colin King
2017-07-27 6:05 ` Tero Kristo
@ 2017-09-01 1:45 ` Stephen Boyd
1 sibling, 0 replies; 3+ messages in thread
From: Stephen Boyd @ 2017-09-01 1:45 UTC (permalink / raw)
To: Colin King
Cc: Tero Kristo, Michael Turquette, linux-omap, linux-clk,
linux-kernel
On 07/27, 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>
> ---
Applied to clk-next
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-09-01 1:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-26 23:56 [PATCH][next] clk: ti: check for null return in strrchr to avoid null dereferencing Colin King
2017-07-27 6:05 ` Tero Kristo
2017-09-01 1:45 ` Stephen Boyd
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).