Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1697637 > unrolled thread
| Started by | Colin King <colin.king@canonical.com> |
|---|---|
| First post | 2017-07-27 02:00 +0200 |
| Last post | 2017-07-27 08:10 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH][next] clk: ti: check for null return in strrchr to avoid null dereferencing Colin King <colin.king@canonical.com> - 2017-07-27 02:00 +0200
Re: [PATCH][next] clk: ti: check for null return in strrchr to avoid null dereferencing Tero Kristo <t-kristo@ti.com> - 2017-07-27 08:10 +0200
| From | Colin King <colin.king@canonical.com> |
|---|---|
| Date | 2017-07-27 02:00 +0200 |
| Subject | [PATCH][next] clk: ti: check for null return in strrchr to avoid null dereferencing |
| Message-ID | <u7EnD-6Zb-9@gated-at.bofh.it> |
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
[toc] | [next] | [standalone]
| From | Tero Kristo <t-kristo@ti.com> |
|---|---|
| Date | 2017-07-27 08:10 +0200 |
| Subject | Re: [PATCH][next] clk: ti: check for null return in strrchr to avoid null dereferencing |
| Message-ID | <u7K9I-2u0-5@gated-at.bofh.it> |
| In reply to | #1697637 |
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>
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web