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.

fwctl/mlx5: Fix memory alloc/free in mlx5ctl_fw_rpc()

Use kvfree() to free memory allocated by kvzalloc() instead of kfree().
Avoid potential memory management issue considering kvzalloc() can
internally choose to use either kmalloc() or vmalloc() based on memory
request and current system memory state. Hence, use more appropriate
kvfree() which automatically determines correct free method to avoid
potential hard to debug memory issues. Fix this issue discovered by
running spatch static analysis tool using coccinelle script -
scripts/coccinelle/api/kfree_mismatch.cocci

Fixes: 52929c2142041 ("fwctl/mlx5: Support for communicating with mlx5 fw")
Link: https://patch.msgid.link/r/aKAjCoF9cT3VEbSE@bhairav-test.ee.iitb.ac.in
Signed-off-by: Akhilesh Patil <akhilesh@ee.iitb.ac.in>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Reviewed-by: Alison Schofield <alison.schofield@intel.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>

authored by

Akhilesh Patil and committed by
Jason Gunthorpe
7f059e47 c17b750b

+1 -1
+1 -1
drivers/fwctl/mlx5/main.c
··· 345 345 */ 346 346 if (ret && ret != -EREMOTEIO) { 347 347 if (rpc_out != rpc_in) 348 - kfree(rpc_out); 348 + kvfree(rpc_out); 349 349 return ERR_PTR(ret); 350 350 } 351 351 return rpc_out;