linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bjorn Andersson <bjorn.andersson@linaro.org>
To: Guo Zhengkui <guozhengkui@vivo.com>
Cc: Andy Gross <agross@kernel.org>,
	Kishon Vijay Abraham I <kishon@ti.com>,
	Vinod Koul <vkoul@kernel.org>,
	"open list:ARM/QUALCOMM SUPPORT" <linux-arm-msm@vger.kernel.org>,
	"open list:GENERIC PHY FRAMEWORK" <linux-phy@lists.infradead.org>,
	open list <linux-kernel@vger.kernel.org>,
	kernel <kernel@vivo.com>
Subject: Re: [PATCH] phy: qcom: fix bug: application of sizeof to pointer
Date: Wed, 8 Dec 2021 08:29:01 -0800	[thread overview]
Message-ID: <YbDdTYny9VXtmzb7@ripper> (raw)
In-Reply-To: <f0a6ae0e-4a6c-7db5-7924-a957f1a0b70b@vivo.com>

On Tue 07 Dec 22:56 PST 2021, Guo Zhengkui wrote:

> On 2021/12/7 23:13, Bjorn Andersson wrote:
> > On Tue 07 Dec 05:16 PST 2021, Guo Zhengkui wrote:
> > 
> > > Fix following coccicheck error:
> > > ./drivers/phy/qualcomm/phy-qcom-edp.c:574:31-37:
> > > ERROR: application of sizeof to pointer.
> > > 
> > > Use sizeof(*data) instead.
> > > 
> > > Signed-off-by: Guo Zhengkui <guozhengkui@vivo.com>
> > > ---
> > >   drivers/phy/qualcomm/phy-qcom-edp.c | 2 +-
> > >   1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/phy/qualcomm/phy-qcom-edp.c b/drivers/phy/qualcomm/phy-qcom-edp.c
> > > index 17d5653b661d..5fe4eab9cac1 100644
> > > --- a/drivers/phy/qualcomm/phy-qcom-edp.c
> > > +++ b/drivers/phy/qualcomm/phy-qcom-edp.c
> > > @@ -571,7 +571,7 @@ static int qcom_edp_clks_register(struct qcom_edp *edp, struct device_node *np)
> > >   	struct clk_init_data init = { };
> > >   	int ret;
> > > -	data = devm_kzalloc(edp->dev, sizeof(data), GFP_KERNEL);
> > > +	data = devm_kzalloc(edp->dev, sizeof(*data), GFP_KERNEL);
> > 
> > Ouch, thanks for catching that!
> > 
> > But the clk_hw_onecell_data actually has a variable size array at the
> > end and as you can see further down I store 2 items in that array.
> > 
> > So that sizeof should be struct_size(data, hws, 2)
> > 
> > Would you be willing to update your patch with that?
> > 
> 
> OK, I will commit another patch. Do you mind I add a "Suggested-by" tag of
> your name in the new patch?
> 

I don't mind.

Regards,
Bjorn

> Zhengkui
> 
> > And please add:
> > Fixes: f199223cb490 ("phy: qcom: Introduce new eDP PHY driver")
> > 
> > Regards,
> > Bjorn
> > 
> > >   	if (!data)
> > >   		return -ENOMEM;
> > > -- 
> > > 2.20.1
> > > 

  reply	other threads:[~2021-12-08 16:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-07 13:16 [PATCH] phy: qcom: fix bug: application of sizeof to pointer Guo Zhengkui
2021-12-07 15:13 ` Bjorn Andersson
     [not found] ` <AO6AKgBME5Y4PNQLIg0Wlap9.9.1638889943341.Hmail.guozhengkui@vivo.com.@PFlhOTZLT3luc080NzhjVnhAcmlwcGVyPg==>
2021-12-08  6:56   ` Guo Zhengkui
2021-12-08 16:29     ` Bjorn Andersson [this message]
2021-12-09  3:21 ` [PATCH] phy: qcom: use struct_size instead of sizeof Guo Zhengkui
2021-12-09  4:50   ` Bjorn Andersson
2021-12-09 11:55   ` Vinod Koul

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=YbDdTYny9VXtmzb7@ripper \
    --to=bjorn.andersson@linaro.org \
    --cc=agross@kernel.org \
    --cc=guozhengkui@vivo.com \
    --cc=kernel@vivo.com \
    --cc=kishon@ti.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-phy@lists.infradead.org \
    --cc=vkoul@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).