Skip to content

Commit 7f6ac72

Browse files
skittbebarino
authored andcommitted
clk/ti/adpll: allocate room for terminating null
The buffer allocated in ti_adpll_clk_get_name doesn't account for the terminating null. This patch switches to devm_kasprintf to avoid overflowing. Signed-off-by: Stephen Kitt <[email protected]> Link: https://lkml.kernel.org/r/[email protected] Acked-by: Tony Lindgren <[email protected]> Signed-off-by: Stephen Boyd <[email protected]>
1 parent 0493258 commit 7f6ac72

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

drivers/clk/ti/adpll.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -194,15 +194,8 @@ static const char *ti_adpll_clk_get_name(struct ti_adpll_data *d,
194194
if (err)
195195
return NULL;
196196
} else {
197-
const char *base_name = "adpll";
198-
char *buf;
199-
200-
buf = devm_kzalloc(d->dev, 8 + 1 + strlen(base_name) + 1 +
201-
strlen(postfix), GFP_KERNEL);
202-
if (!buf)
203-
return NULL;
204-
sprintf(buf, "%08lx.%s.%s", d->pa, base_name, postfix);
205-
name = buf;
197+
name = devm_kasprintf(d->dev, GFP_KERNEL, "%08lx.adpll.%s",
198+
d->pa, postfix);
206199
}
207200

208201
return name;

0 commit comments

Comments
 (0)