Re: [PATCH] fpga: dfl: fix potential memory leak in vfio_intx_enable()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Jun 23, 2024 at 03:40:19PM +0800, Ma Ke wrote:
> We should free 'feature->irq_ctx[idx].name' to avoid 'name'
> memory leak when request_irq() failed.
> 
> Signed-off-by: Ma Ke <make24@xxxxxxxxxxx>
> ---
>  drivers/fpga/dfl.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/fpga/dfl.c b/drivers/fpga/dfl.c
> index 094ee97ea26c..c52ebece5aef 100644
> --- a/drivers/fpga/dfl.c
> +++ b/drivers/fpga/dfl.c
> @@ -1911,7 +1911,7 @@ static int do_set_irq_trigger(struct dfl_feature *feature, unsigned int idx,
>  			  feature->irq_ctx[idx].name, trigger);
>  	if (!ret) {
>  		feature->irq_ctx[idx].trigger = trigger;
> -		return ret;
> +		goto free_name;

I believe (!ret) represents the success case and that simply
returning is the right thing to do. In the case of an error,
eventfd_ctx_put() and kfree() are both called.

>  	}
>  
>  	eventfd_ctx_put(trigger);
> -- 
> 2.25.1
> 




[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux