Skip to content

Commit 7f059e4

Browse files
Akhilesh Patiljgunthorpe
authored andcommitted
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: 52929c2 ("fwctl/mlx5: Support for communicating with mlx5 fw") Link: https://patch.msgid.link/r/[email protected] Signed-off-by: Akhilesh Patil <[email protected]> Reviewed-by: Dave Jiang <[email protected]> Reviewed-by: Alison Schofield <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent c17b750 commit 7f059e4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/fwctl/mlx5/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ static void *mlx5ctl_fw_rpc(struct fwctl_uctx *uctx, enum fwctl_rpc_scope scope,
345345
*/
346346
if (ret && ret != -EREMOTEIO) {
347347
if (rpc_out != rpc_in)
348-
kfree(rpc_out);
348+
kvfree(rpc_out);
349349
return ERR_PTR(ret);
350350
}
351351
return rpc_out;

0 commit comments

Comments
 (0)