Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

regulator: qcom_rpm-regulator: Use devm_kmemdup to replace devm_kmalloc + memcpy

Use the helper function devm_kmemdup() rather than duplicating its
implementation, which helps to enhance code readability.

Signed-off-by: Li Zetao <lizetao1@huawei.com>
Link: https://lore.kernel.org/r/20230810114858.2103928-1-lizetao1@huawei.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Li Zetao and committed by
Mark Brown
55975401 252b9116

+1 -2
+1 -2
drivers/regulator/qcom_rpm-regulator.c
··· 956 956 } 957 957 958 958 for (reg = match->data; reg->name; reg++) { 959 - vreg = devm_kmalloc(&pdev->dev, sizeof(*vreg), GFP_KERNEL); 959 + vreg = devm_kmemdup(&pdev->dev, reg->template, sizeof(*vreg), GFP_KERNEL); 960 960 if (!vreg) 961 961 return -ENOMEM; 962 962 963 - memcpy(vreg, reg->template, sizeof(*vreg)); 964 963 mutex_init(&vreg->lock); 965 964 966 965 vreg->dev = &pdev->dev;