Re: [PATCH v2] fwctl: mlx5: fix memory alloc/free in mlx5ctl_fw_rpc()

From: Alison Schofield
Date: Mon Aug 18 2025 - 14:34:03 EST


On Sat, Aug 16, 2025 at 11:49:54AM +0530, Akhilesh Patil wrote:
> 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")
> Signed-off-by: Akhilesh Patil <akhilesh@xxxxxxxxxxxxx>
> Reviewed-by: Dave Jiang <dave.jiang@xxxxxxxxx>
> ---
> changes v1 -> v2:
> - Update commit message with details on why this issue needs to be fixed
> as suggested by Alison <alison.schofield@xxxxxxxxx>
> - Update commit message with details on how this issue was discovered
> using coccinelle scripts as suggested by Markus <Markus.Elfring@xxxxxx>
> - Carry forward Reviewd-by tag from Dave Jiang <dave.jiang@xxxxxxxxx>


Reviewed-by: Alison Schofield <alison.schofield@xxxxxxxxx>