Skip to content

Commit 41d826c

Browse files
eleanorLYJkeithbusch
authored andcommitted
nvmet: replace kmalloc + memset with kzalloc for data allocation
cocci warnings: (new ones prefixed by >>) >> drivers/nvme/target/pr.c:831:8-15: WARNING: kzalloc should be used for data, instead of kmalloc/memset The pattern of using 'kmalloc' followed by 'memset' is replaced with 'kzalloc', which is functionally equivalent to 'kmalloc' + 'memset', but more efficient. 'kzalloc' automatically zeroes the allocated memory, making it a faster and more streamlined solution. Reported-by: kernel test robot <[email protected]> Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/ Reviewed-by: Kuan-Wei Chiu <[email protected]> Reviewed-by: Chaitanya Kulkarni <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: Yu-Chun Lin <[email protected]> Signed-off-by: Keith Busch <[email protected]>
1 parent 88c23a3 commit 41d826c

File tree

1 file changed

+1
-2
lines changed
  • drivers/nvme/target

1 file changed

+1
-2
lines changed

drivers/nvme/target/pr.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -828,12 +828,11 @@ static void nvmet_execute_pr_report(struct nvmet_req *req)
828828
goto out;
829829
}
830830

831-
data = kmalloc(num_bytes, GFP_KERNEL);
831+
data = kzalloc(num_bytes, GFP_KERNEL);
832832
if (!data) {
833833
status = NVME_SC_INTERNAL;
834834
goto out;
835835
}
836-
memset(data, 0, num_bytes);
837836
data->gen = cpu_to_le32(atomic_read(&pr->generation));
838837
data->ptpls = 0;
839838
ctrl_eds = data->regctl_eds;

0 commit comments

Comments
 (0)