All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Richard Gong <richard.gong@linux.intel.com>
Cc: Christophe JAILLET <christophe.jaillet@wanadoo.fr>,
	gregkh@linuxfoundation.org, atull@kernel.org,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] firmware: stratix10-svc: Fix a resource leak in an error handling path
Date: Thu, 27 May 2021 13:36:41 +0300	[thread overview]
Message-ID: <20210527103641.GS1955@kadam> (raw)
In-Reply-To: <f669ed42-348f-808b-afeb-9528d2ece6ee@linux.intel.com>

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



      reply	other threads:[~2021-05-27 10:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-21 18:22 [PATCH] firmware: stratix10-svc: Fix a resource leak in an error handling path Christophe JAILLET
2021-05-26 19:13 ` Richard Gong
2021-05-27 10:36   ` Dan Carpenter [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210527103641.GS1955@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=atull@kernel.org \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=gregkh@linuxfoundation.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=richard.gong@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.