]> Git Repo - J-linux.git/commitdiff
iommu/dart: Use kmemdup instead of kzalloc and memcpy
authorWan Jiabing <[email protected]>
Wed, 13 Oct 2021 06:34:41 +0000 (02:34 -0400)
committerJoerg Roedel <[email protected]>
Mon, 18 Oct 2021 11:35:24 +0000 (13:35 +0200)
Fix following coccicheck warning:
drivers/iommu/apple-dart.c:704:20-27: WARNING opportunity for kmemdup

Signed-off-by: Wan Jiabing <[email protected]>
Acked-by: Sven Peter <[email protected]>
Reviewed-by: Alyssa Rosenzweig <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Joerg Roedel <[email protected]>
drivers/iommu/apple-dart.c

index fdfa39ec2a4d4a50d87d5fa9502efc7b1170bc61..13ba258b7413400a1e3c71d1bddd99d71ce780fd 100644 (file)
@@ -702,13 +702,12 @@ static struct iommu_group *apple_dart_device_group(struct device *dev)
        if (!group)
                goto out;
 
-       group_master_cfg = kzalloc(sizeof(*group_master_cfg), GFP_KERNEL);
+       group_master_cfg = kmemdup(cfg, sizeof(*group_master_cfg), GFP_KERNEL);
        if (!group_master_cfg) {
                iommu_group_put(group);
                goto out;
        }
 
-       memcpy(group_master_cfg, cfg, sizeof(*group_master_cfg));
        iommu_group_set_iommudata(group, group_master_cfg,
                apple_dart_release_group);
 
This page took 0.050775 seconds and 4 git commands to generate.