Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1587932 > unrolled thread

Re: [PATCH] clk: core: Copy connection id

Started byStephen Boyd <sboyd@codeaurora.org>
First post2017-02-24 21:50 +0100
Last post2017-02-28 09:20 +0100
Articles 3 — 3 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH] clk: core: Copy connection id Stephen Boyd <sboyd@codeaurora.org> - 2017-02-24 21:50 +0100
    Re: [PATCH] clk: core: Copy connection id Leonard Crestez <leonard.crestez@nxp.com> - 2017-02-25 10:40 +0100
      Re: [PATCH] clk: core: Copy connection id "sboyd@codeaurora.org" <sboyd@codeaurora.org> - 2017-02-28 09:20 +0100

#1587932 — Re: [PATCH] clk: core: Copy connection id

FromStephen Boyd <sboyd@codeaurora.org>
Date2017-02-24 21:50 +0100
SubjectRe: [PATCH] clk: core: Copy connection id
Message-ID<teuYp-5wX-7@gated-at.bofh.it>
On 02/20, Leonard Crestez wrote:
> Some drivers use sprintf to build clk connection id names but the clk
> core will save those strings and occasionally print them back. Duplicate
> the con_id strings instead of fixing all the users.
> 
> Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>
> ---
>  drivers/clk/clk.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> Some examples of using sprintf for con_id include:
> drivers/mfd/omap-usb-host.c
> drivers/tty/serial/samsung.c
> sound/soc/fsl/fsl_asrc.c
> 
> There are lots more. They are difficult to find and "fixing" them on the
> consumer side requires nasty code to keep track of the allocated clkname.

Good catch. What about dev_id though? That could also have the
same problem if some device is removed and we're still holding a
reference to the kobject's name. This is probably more rare than
what is happening here, but still seems possible that we might
trip over that later.

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

[toc] | [next] | [standalone]


#1588100

FromLeonard Crestez <leonard.crestez@nxp.com>
Date2017-02-25 10:40 +0100
Message-ID<teGZz-5LV-3@gated-at.bofh.it>
In reply to#1587932
On Fri, 2017-02-24 at 12:44 -0800, Stephen Boyd wrote:
> On 02/20, Leonard Crestez wrote:
> > Some drivers use sprintf to build clk connection id names but the
> > clk
> > core will save those strings and occasionally print them back.
> > Duplicate
> > the con_id strings instead of fixing all the users.
> 
> Good catch. What about dev_id though? That could also have the
> same problem if some device is removed and we're still holding a
> reference to the kobject's name. This is probably more rare than
> what is happening here, but still seems possible that we might
> trip over that later.

A device should normally free the clks it uses before it is destroyed.
This means that if dev_id is pointing to freed memory then the clk
itself was probably leaked, right?

This is obvious misuse of the API, not like sprintf-ing a con_id in a
complex driver. I don't really think it's worth copying strings for it.

--
Regards,
Leonard

[toc] | [prev] | [next] | [standalone]


#1589269

From"sboyd@codeaurora.org" <sboyd@codeaurora.org>
Date2017-02-28 09:20 +0100
Message-ID<tfLaO-1Kw-7@gated-at.bofh.it>
In reply to#1588100
On 02/25, Leonard Crestez wrote:
> On Fri, 2017-02-24 at 12:44 -0800, Stephen Boyd wrote:
> > On 02/20, Leonard Crestez wrote:
> > > Some drivers use sprintf to build clk connection id names but the
> > > clk
> > > core will save those strings and occasionally print them back.
> > > Duplicate
> > > the con_id strings instead of fixing all the users.
> > 
> > Good catch. What about dev_id though? That could also have the
> > same problem if some device is removed and we're still holding a
> > reference to the kobject's name. This is probably more rare than
> > what is happening here, but still seems possible that we might
> > trip over that later.
> 
> A device should normally free the clks it uses before it is destroyed.
> This means that if dev_id is pointing to freed memory then the clk
> itself was probably leaked, right?

Sure. clk_get_sys() could be called and then we could have
something sprintf the dev_id there. A quick grep doesn't show any
place where that happens though so it seems safe right now.

That said, it would be nice to clearly document that we don't
expect dev_id to be freed or changed during the lifetime of the
clk structure, but we do allow con_id to change. Perhaps the copy
shows that, but a comment would also be useful so we don't have
people wondering why dev_id isn't copied as well.

> 
> This is obvious misuse of the API, not like sprintf-ing a con_id in a
> complex driver. I don't really think it's worth copying strings for it.
> 

Ok.

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web