Skip to content

Commit

Permalink
i2c: Improve size determinations
Browse files Browse the repository at this point in the history
[ Upstream commit 06e9895 ]

Replace the specification of a data structure by a pointer dereference
as the parameter for the operator "sizeof" to make the corresponding
size determination a bit safer according to the Linux coding style
convention.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
Stable-dep-of: 05f933d ("i2c: nomadik: Remove a useless call in the remove function")
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
elfring authored and gregkh committed Aug 3, 2023
1 parent 576c5fa commit 00f3867
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion drivers/i2c/busses/i2c-nomadik.c
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,7 @@ static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id)
struct i2c_vendor_data *vendor = id->data;
u32 max_fifo_threshold = (vendor->fifodepth / 2) - 1;

dev = devm_kzalloc(&adev->dev, sizeof(struct nmk_i2c_dev), GFP_KERNEL);
dev = devm_kzalloc(&adev->dev, sizeof(*dev), GFP_KERNEL);
if (!dev) {
ret = -ENOMEM;
goto err_no_mem;
Expand Down
2 changes: 1 addition & 1 deletion drivers/i2c/busses/i2c-sh7760.c
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ static int sh7760_i2c_probe(struct platform_device *pdev)
goto out0;
}

id = kzalloc(sizeof(struct cami2c), GFP_KERNEL);
id = kzalloc(sizeof(*id), GFP_KERNEL);
if (!id) {
ret = -ENOMEM;
goto out0;
Expand Down

0 comments on commit 00f3867

Please sign in to comment.