[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211209032114.9416-1-guozhengkui@vivo.com>
Date: Thu, 9 Dec 2021 11:21:14 +0800
From: Guo Zhengkui <guozhengkui@...o.com>
To: Andy Gross <agross@...nel.org>,
Bjorn Andersson <bjorn.andersson@...aro.org>,
Kishon Vijay Abraham I <kishon@...com>,
Vinod Koul <vkoul@...nel.org>,
linux-arm-msm@...r.kernel.org (open list:ARM/QUALCOMM SUPPORT),
linux-phy@...ts.infradead.org (open list:GENERIC PHY FRAMEWORK),
linux-kernel@...r.kernel.org (open list)
Cc: kernel@...o.com, Guo Zhengkui <guozhengkui@...o.com>
Subject: [PATCH] phy: qcom: use struct_size instead of sizeof
Use struct_size() to get the accurate size of `clk_hw_onecell_data`
with a variable size array, instead of sizeof(data) to get the size
of a pointer.
Suggested-by: Bjorn Andersson <bjorn.andersson@...aro.org>
Signed-off-by: Guo Zhengkui <guozhengkui@...o.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..a8ecd2e8442d 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, struct_size(data, hws, 2), GFP_KERNEL);
if (!data)
return -ENOMEM;
--
2.20.1
Powered by blists - more mailing lists