projects
/
platform
/
kernel
/
linux-starfive.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
7bc1cfa
)
soc: qcom: smem: Use struct_size()
author
Christophe JAILLET
<christophe.jaillet@wanadoo.fr>
Wed, 12 Jul 2023 20:42:15 +0000
(22:42 +0200)
committer
Bjorn Andersson
<andersson@kernel.org>
Fri, 14 Jul 2023 03:21:26 +0000
(20:21 -0700)
Use struct_size() instead of hand-writing it, when allocating a structure
with a flex array.
This is less verbose.
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Kees Cook <keescook@chromium.org>
Link:
https://lore.kernel.org/r/f74328551cfab0262ba353f37d047ac74bf616e1.1689194490.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
drivers/soc/qcom/smem.c
patch
|
blob
|
history
diff --git
a/drivers/soc/qcom/smem.c
b/drivers/soc/qcom/smem.c
index
b0d59e8
..
776096b
100644
(file)
--- a/
drivers/soc/qcom/smem.c
+++ b/
drivers/soc/qcom/smem.c
@@
-1059,7
+1059,6
@@
static int qcom_smem_probe(struct platform_device *pdev)
struct reserved_mem *rmem;
struct qcom_smem *smem;
unsigned long flags;
- size_t array_size;
int num_regions;
int hwlock_id;
u32 version;
@@
-1071,8
+1070,8
@@
static int qcom_smem_probe(struct platform_device *pdev)
if (of_property_present(pdev->dev.of_node, "qcom,rpm-msg-ram"))
num_regions++;
- array_size = num_regions * sizeof(struct smem_region);
-
smem = devm_kzalloc(&pdev->dev, sizeof(*smem) + array_size,
GFP_KERNEL);
+ smem = devm_kzalloc(&pdev->dev, struct_size(smem, regions, num_regions),
+
GFP_KERNEL);
if (!smem)
return -ENOMEM;