All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Boyd <sboyd@codeaurora.org>
To: Julia Lawall <julia.lawall@lip6.fr>
Cc: mturquette@baylibre.com, linux-clk@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: question about clk_hw_register_fixed_factor
Date: Tue, 20 Sep 2016 10:31:05 -0700	[thread overview]
Message-ID: <20160920173105.GA8319@codeaurora.org> (raw)
In-Reply-To: <alpine.DEB.2.10.1609200811560.3346@hadrien>

On 09/20, Julia Lawall wrote:
> Hello,
> 
> The function clk_hw_register_fixed_factor from
> drivers/clk/clk-fixed-factor.c contains:
> 
> struct clk_init_data init;
> ...
> fix->hw.init = &init;
> ...
> hw = &fix->hw;
> ...
> return hw;
> 
> It looks like hw would then contain a dangling pointer, to init.  Should
> this be nulled out, or does it not matter because it is certain that no
> one will look at it anyway?  Or did I miss a null assignment elsewhere?
> 

Yes this is a common pattern in clk drivers. The init structure
is not used after clk_register() (or its variants) is called, so
there will typically be a dangling pointer in clk_hw to the
clk_init_data structure. Sometimes that structure is allocated on
the stack, which leads to other problems like people forgetting
to initialize all the members. Usually they forgot to set flags
to something and then clk framework does very odd things. We
could null out the init pointer if we really cared, but so far
this hasn't been a problem.

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

  reply	other threads:[~2016-09-20 17:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-20  6:15 question about clk_hw_register_fixed_factor Julia Lawall
2016-09-20 17:31 ` Stephen Boyd [this message]
2016-09-20 17:32   ` Julia Lawall

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=20160920173105.GA8319@codeaurora.org \
    --to=sboyd@codeaurora.org \
    --cc=julia.lawall@lip6.fr \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mturquette@baylibre.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.