OSDN Git Service

phy: qcom: use struct_size instead of sizeof
authorGuo Zhengkui <guozhengkui@vivo.com>
Thu, 9 Dec 2021 03:21:14 +0000 (11:21 +0800)
committerVinod Koul <vkoul@kernel.org>
Thu, 9 Dec 2021 11:54:54 +0000 (17:24 +0530)
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@linaro.org>
Signed-off-by: Guo Zhengkui <guozhengkui@vivo.com>
Fixes: f199223cb490 ("phy: qcom: Introduce new eDP PHY driver")
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Link: https://lore.kernel.org/r/20211209032114.9416-1-guozhengkui@vivo.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/phy/qualcomm/phy-qcom-edp.c

index 17d5653..a8ecd2e 100644 (file)
@@ -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;