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.

IB/hfi1: kzalloc to kzalloc_flex

Combine kzalloc and kcalloc with a flexible array member. Avoids having
to free separately.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Link: https://patch.msgid.link/20260309215017.4753-1-rosenp@gmail.com
Signed-off-by: Leon Romanovsky <leon@kernel.org>

authored by

Rosen Penev and committed by
Leon Romanovsky
56521f58 1b50f420

+2 -9
+1 -8
drivers/infiniband/hw/hfi1/user_exp_rcv.c
··· 257 257 if (tinfo->length == 0) 258 258 return -EINVAL; 259 259 260 - tidbuf = kzalloc_obj(*tidbuf); 260 + tidbuf = kzalloc_flex(*tidbuf, psets, uctxt->expected_count); 261 261 if (!tidbuf) 262 262 return -ENOMEM; 263 263 ··· 265 265 tidbuf->vaddr = tinfo->vaddr; 266 266 tidbuf->length = tinfo->length; 267 267 tidbuf->npages = num_user_pages(tidbuf->vaddr, tidbuf->length); 268 - tidbuf->psets = kzalloc_objs(*tidbuf->psets, uctxt->expected_count); 269 - if (!tidbuf->psets) { 270 - ret = -ENOMEM; 271 - goto fail_release_mem; 272 - } 273 268 274 269 if (fd->use_mn) { 275 270 ret = mmu_interval_notifier_insert( ··· 442 447 if (fd->use_mn) 443 448 mmu_interval_notifier_remove(&tidbuf->notifier); 444 449 kfree(tidbuf->pages); 445 - kfree(tidbuf->psets); 446 450 kfree(tidbuf); 447 451 kfree(tidlist); 448 452 return 0; ··· 464 470 unpin_rcv_pages(fd, tidbuf, NULL, 0, pinned, false); 465 471 fail_release_mem: 466 472 kfree(tidbuf->pages); 467 - kfree(tidbuf->psets); 468 473 kfree(tidbuf); 469 474 kfree(tidlist); 470 475 return ret;
+1 -1
drivers/infiniband/hw/hfi1/user_exp_rcv.h
··· 22 22 unsigned long length; 23 23 unsigned int npages; 24 24 struct page **pages; 25 - struct tid_pageset *psets; 26 25 unsigned int n_psets; 26 + struct tid_pageset psets[]; 27 27 }; 28 28 29 29 struct tid_rb_node {