* [PATCH] fpga: dfl: afu: use kzalloc_obj over kzalloc with sizeof
@ 2026-05-11 18:12 Mayur Kumar
2026-05-13 10:13 ` kernel test robot
2026-05-13 11:07 ` kernel test robot
0 siblings, 2 replies; 3+ messages in thread
From: Mayur Kumar @ 2026-05-11 18:12 UTC (permalink / raw)
To: yilun.xu, mdf; +Cc: trix, linux-fpga, linux-kernel, Mayur Kumar
The checkpatch tool prefers the use of kzalloc_obj() as it provides
better type safety and conciseness compared to kzalloc() with
an explicit sizeof().
Signed-off-by: Mayur Kumar <kmayur809@gmail.com>
---
drivers/fpga/dfl-afu-dma-region.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/fpga/dfl-afu-dma-region.c b/drivers/fpga/dfl-afu-dma-region.c
index 87652d58d03..8a9d705ebe3 100644
--- a/drivers/fpga/dfl-afu-dma-region.c
+++ b/drivers/fpga/dfl-afu-dma-region.c
@@ -316,7 +316,7 @@ int afu_dma_map_region(struct dfl_feature_dev_data *fdata,
if (user_addr + length < user_addr)
return -EINVAL;
- region = kzalloc(sizeof(*region), GFP_KERNEL);
+ region = kzalloc_obj(region, GFP_KERNEL);
if (!region)
return -ENOMEM;
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] fpga: dfl: afu: use kzalloc_obj over kzalloc with sizeof
2026-05-11 18:12 [PATCH] fpga: dfl: afu: use kzalloc_obj over kzalloc with sizeof Mayur Kumar
@ 2026-05-13 10:13 ` kernel test robot
2026-05-13 11:07 ` kernel test robot
1 sibling, 0 replies; 3+ messages in thread
From: kernel test robot @ 2026-05-13 10:13 UTC (permalink / raw)
To: Mayur Kumar, yilun.xu, mdf
Cc: oe-kbuild-all, trix, linux-fpga, linux-kernel, Mayur Kumar
Hi Mayur,
kernel test robot noticed the following build errors:
[auto build test ERROR on linus/master]
[also build test ERROR on v7.1-rc3 next-20260508]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Mayur-Kumar/fpga-dfl-afu-use-kzalloc_obj-over-kzalloc-with-sizeof/20260513-141558
base: linus/master
patch link: https://lore.kernel.org/r/20260511181240.223224-1-kmayur809%40gmail.com
patch subject: [PATCH] fpga: dfl: afu: use kzalloc_obj over kzalloc with sizeof
config: nios2-randconfig-002-20260513 (https://download.01.org/0day-ci/archive/20260513/202605131843.wVRKksBi-lkp@intel.com/config)
compiler: nios2-linux-gcc (GCC) 8.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260513/202605131843.wVRKksBi-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202605131843.wVRKksBi-lkp@intel.com/
All errors (new ones prefixed by >>):
drivers/fpga/dfl-afu-dma-region.c: In function 'afu_dma_map_region':
>> drivers/fpga/dfl-afu-dma-region.c:319:9: error: assignment to 'struct dfl_afu_dma_region *' from incompatible pointer type 'struct dfl_afu_dma_region **' [-Werror=incompatible-pointer-types]
region = kzalloc_obj(region, GFP_KERNEL);
^
cc1: some warnings being treated as errors
vim +319 drivers/fpga/dfl-afu-dma-region.c
289
290 /**
291 * afu_dma_map_region - map memory region for dma
292 * @fdata: feature dev data
293 * @user_addr: address of the memory region
294 * @length: size of the memory region
295 * @iova: pointer of iova address
296 *
297 * Map memory region defined by @user_addr and @length, and return dma address
298 * of the memory region via @iova.
299 * Return 0 for success, otherwise error code.
300 */
301 int afu_dma_map_region(struct dfl_feature_dev_data *fdata,
302 u64 user_addr, u64 length, u64 *iova)
303 {
304 struct device *dev = &fdata->dev->dev;
305 struct dfl_afu_dma_region *region;
306 int ret;
307
308 /*
309 * Check Inputs, only accept page-aligned user memory region with
310 * valid length.
311 */
312 if (!PAGE_ALIGNED(user_addr) || !PAGE_ALIGNED(length) || !length)
313 return -EINVAL;
314
315 /* Check overflow */
316 if (user_addr + length < user_addr)
317 return -EINVAL;
318
> 319 region = kzalloc_obj(region, GFP_KERNEL);
320 if (!region)
321 return -ENOMEM;
322
323 region->user_addr = user_addr;
324 region->length = length;
325
326 /* Pin the user memory region */
327 ret = afu_dma_pin_pages(fdata, region);
328 if (ret) {
329 dev_err(dev, "failed to pin memory region\n");
330 goto free_region;
331 }
332
333 /* Only accept continuous pages, return error else */
334 if (!afu_dma_check_continuous_pages(region)) {
335 dev_err(dev, "pages are not continuous\n");
336 ret = -EINVAL;
337 goto unpin_pages;
338 }
339
340 /* As pages are continuous then start to do DMA mapping */
341 region->iova = dma_map_page(dfl_fpga_fdata_to_parent(fdata),
342 region->pages[0], 0,
343 region->length,
344 DMA_BIDIRECTIONAL);
345 if (dma_mapping_error(dfl_fpga_fdata_to_parent(fdata), region->iova)) {
346 dev_err(dev, "failed to map for dma\n");
347 ret = -EFAULT;
348 goto unpin_pages;
349 }
350
351 *iova = region->iova;
352
353 mutex_lock(&fdata->lock);
354 ret = afu_dma_region_add(fdata, region);
355 mutex_unlock(&fdata->lock);
356 if (ret) {
357 dev_err(dev, "failed to add dma region\n");
358 goto unmap_dma;
359 }
360
361 return 0;
362
363 unmap_dma:
364 dma_unmap_page(dfl_fpga_fdata_to_parent(fdata),
365 region->iova, region->length, DMA_BIDIRECTIONAL);
366 unpin_pages:
367 afu_dma_unpin_pages(fdata, region);
368 free_region:
369 kfree(region);
370 return ret;
371 }
372
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] fpga: dfl: afu: use kzalloc_obj over kzalloc with sizeof
2026-05-11 18:12 [PATCH] fpga: dfl: afu: use kzalloc_obj over kzalloc with sizeof Mayur Kumar
2026-05-13 10:13 ` kernel test robot
@ 2026-05-13 11:07 ` kernel test robot
1 sibling, 0 replies; 3+ messages in thread
From: kernel test robot @ 2026-05-13 11:07 UTC (permalink / raw)
To: Mayur Kumar, yilun.xu, mdf
Cc: llvm, oe-kbuild-all, trix, linux-fpga, linux-kernel, Mayur Kumar
Hi Mayur,
kernel test robot noticed the following build errors:
[auto build test ERROR on linus/master]
[also build test ERROR on v7.1-rc3 next-20260508]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Mayur-Kumar/fpga-dfl-afu-use-kzalloc_obj-over-kzalloc-with-sizeof/20260513-141558
base: linus/master
patch link: https://lore.kernel.org/r/20260511181240.223224-1-kmayur809%40gmail.com
patch subject: [PATCH] fpga: dfl: afu: use kzalloc_obj over kzalloc with sizeof
config: i386-buildonly-randconfig-004-20260513 (https://download.01.org/0day-ci/archive/20260513/202605131802.mIyi1UXu-lkp@intel.com/config)
compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260513/202605131802.mIyi1UXu-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202605131802.mIyi1UXu-lkp@intel.com/
All errors (new ones prefixed by >>):
>> drivers/fpga/dfl-afu-dma-region.c:319:9: error: incompatible pointer types assigning to 'struct dfl_afu_dma_region *' from 'typeof (region) *' (aka 'struct dfl_afu_dma_region **'); dereference with * [-Werror,-Wincompatible-pointer-types]
319 | region = kzalloc_obj(region, GFP_KERNEL);
| ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| *( )
1 error generated.
vim +319 drivers/fpga/dfl-afu-dma-region.c
289
290 /**
291 * afu_dma_map_region - map memory region for dma
292 * @fdata: feature dev data
293 * @user_addr: address of the memory region
294 * @length: size of the memory region
295 * @iova: pointer of iova address
296 *
297 * Map memory region defined by @user_addr and @length, and return dma address
298 * of the memory region via @iova.
299 * Return 0 for success, otherwise error code.
300 */
301 int afu_dma_map_region(struct dfl_feature_dev_data *fdata,
302 u64 user_addr, u64 length, u64 *iova)
303 {
304 struct device *dev = &fdata->dev->dev;
305 struct dfl_afu_dma_region *region;
306 int ret;
307
308 /*
309 * Check Inputs, only accept page-aligned user memory region with
310 * valid length.
311 */
312 if (!PAGE_ALIGNED(user_addr) || !PAGE_ALIGNED(length) || !length)
313 return -EINVAL;
314
315 /* Check overflow */
316 if (user_addr + length < user_addr)
317 return -EINVAL;
318
> 319 region = kzalloc_obj(region, GFP_KERNEL);
320 if (!region)
321 return -ENOMEM;
322
323 region->user_addr = user_addr;
324 region->length = length;
325
326 /* Pin the user memory region */
327 ret = afu_dma_pin_pages(fdata, region);
328 if (ret) {
329 dev_err(dev, "failed to pin memory region\n");
330 goto free_region;
331 }
332
333 /* Only accept continuous pages, return error else */
334 if (!afu_dma_check_continuous_pages(region)) {
335 dev_err(dev, "pages are not continuous\n");
336 ret = -EINVAL;
337 goto unpin_pages;
338 }
339
340 /* As pages are continuous then start to do DMA mapping */
341 region->iova = dma_map_page(dfl_fpga_fdata_to_parent(fdata),
342 region->pages[0], 0,
343 region->length,
344 DMA_BIDIRECTIONAL);
345 if (dma_mapping_error(dfl_fpga_fdata_to_parent(fdata), region->iova)) {
346 dev_err(dev, "failed to map for dma\n");
347 ret = -EFAULT;
348 goto unpin_pages;
349 }
350
351 *iova = region->iova;
352
353 mutex_lock(&fdata->lock);
354 ret = afu_dma_region_add(fdata, region);
355 mutex_unlock(&fdata->lock);
356 if (ret) {
357 dev_err(dev, "failed to add dma region\n");
358 goto unmap_dma;
359 }
360
361 return 0;
362
363 unmap_dma:
364 dma_unmap_page(dfl_fpga_fdata_to_parent(fdata),
365 region->iova, region->length, DMA_BIDIRECTIONAL);
366 unpin_pages:
367 afu_dma_unpin_pages(fdata, region);
368 free_region:
369 kfree(region);
370 return ret;
371 }
372
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-05-13 11:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-11 18:12 [PATCH] fpga: dfl: afu: use kzalloc_obj over kzalloc with sizeof Mayur Kumar
2026-05-13 10:13 ` kernel test robot
2026-05-13 11:07 ` kernel test robot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox