Re: [PATCH] firmware: stratix10-svc: Fix a resource leak in an error handling path

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

 



On Wed, May 26, 2021 at 02:13:12PM -0500, Richard Gong wrote:
> >   	dev_set_drvdata(dev, svc);
> >   	pr_info("Intel Service Layer Driver Initialized\n");
> > +	return 0;
> > +
> > +err_put_device:
> > +	platform_device_put(svc->stratix10_svc_rsu);
> > +err_free_kfifo:
> > +	kfifo_free(&controller->svc_fifo);
> 
> Need for the allocated memory pool as well,
> 	if (ctrl->genpool)
>                 gen_pool_destroy(ctrl->genpool);
> 

Good point, but there is no need to check, the genpool is not optional
and the "if (ctrl->genpool)" condition could be deleted from the remove
function as well.

err_put_device:
	platform_device_put(svc->stratix10_svc_rsu);
err_free_kfifo:
	kfifo_free(&controller->svc_fifo);
err_destroy_pool:
	gen_pool_destroy(genpool);

	return ret;

But the other question is what's on with the &svc_ctrl list?  I would
have thought that we needed to remove freed controller from the list as
well, but looking at it now I think the list itself should be removed.
I think there can only be one item in the list at a time.  So we could
just make the controller pointer a file scope global or we could find
some other way to go from the client pointer to the controller pointer.

regards,
dan carpenter





[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux