mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Stephen Kitt <steve@sk2.org>
To: Stephen Boyd <sboyd@kernel.org>
Cc: Michael Turquette <mturquette@baylibre.com>,
	Tero Kristo <t-kristo@ti.com>, Tony Lindgren <tony@atomide.com>,
	linux-clk@vger.kernel.org, linux-omap@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] clk/ti/adpll: allocate room for terminating null
Date: Sat, 19 Oct 2019 15:54:41 +0200	[thread overview]
Message-ID: <20191019155441.2b1b349f@heffalump.sk2.org> (raw)
In-Reply-To: <20191017154854.5285220869@mail.kernel.org>

[-- Attachment #1: Type: text/plain, Size: 1644 bytes --]

On Thu, 17 Oct 2019 08:48:53 -0700, Stephen Boyd <sboyd@kernel.org> wrote:
> Quoting Stephen Kitt (2019-09-27 11:05:59)
> > The buffer allocated in ti_adpll_clk_get_name doesn't account for the
> > terminating null. This patch switches to ka_sprintf to avoid
> > overflowing.
> > 
> > Signed-off-by: Stephen Kitt <steve@sk2.org>
> > ---
> >  drivers/clk/ti/adpll.c | 10 ++--------
> >  1 file changed, 2 insertions(+), 8 deletions(-)
> > 
> > diff --git a/drivers/clk/ti/adpll.c b/drivers/clk/ti/adpll.c
> > index fdfb90058504..021cf9e2b4db 100644
> > --- a/drivers/clk/ti/adpll.c
> > +++ b/drivers/clk/ti/adpll.c
> > @@ -195,14 +195,8 @@ static const char *ti_adpll_clk_get_name(struct
> > ti_adpll_data *d, return NULL;
> >         } else {
> >                 const char *base_name = "adpll";  
> 
> This is used once.
> 
> > -               char *buf;
> > -
> > -               buf = devm_kzalloc(d->dev, 8 + 1 + strlen(base_name) + 1 +
> > -                                   strlen(postfix), GFP_KERNEL);
> > -               if (!buf)
> > -                       return NULL;
> > -               sprintf(buf, "%08lx.%s.%s", d->pa, base_name, postfix);
> > -               name = buf;
> > +               name = devm_kasprintf(d->dev, GFP_KERNEL, "%08lx.%s.%s",  
> 
> So why not make this "%08lx.adpll.%s"?

Thanks for the review! I hesitated to do this because I thought the purely
formatting string "%08lx.%s.%s" made the resulting code easier to understand
than a combined "%08lx.adpll.%s". I’ll follow up with a v3 which merges the
"adpll" string into the format string.

Regards,

Stephen

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2019-10-19 14:33 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-27 14:57 [PATCH] " Stephen Kitt
2019-09-27 15:23 ` Tony Lindgren
2019-09-27 18:00   ` Stephen Kitt
2019-09-27 18:05     ` [PATCH v2] " Stephen Kitt
2019-09-27 18:18       ` Stephen Kitt
2019-10-17 15:48       ` Stephen Boyd
2019-10-19 13:54         ` Stephen Kitt [this message]
2019-10-19 14:06           ` [PATCH v3] " Stephen Kitt
2019-10-21 14:31             ` Tony Lindgren
2019-11-08 17:00             ` Stephen Boyd
2019-11-08 20:17               ` Stephen Kitt
2019-11-08 17:01             ` Stephen Boyd

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191019155441.2b1b349f@heffalump.sk2.org \
    --to=steve@sk2.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=sboyd@kernel.org \
    --cc=t-kristo@ti.com \
    --cc=tony@atomide.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome