netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Ajit Khaparde <ajit.khaparde@broadcom.com>
Cc: Jakub Kicinski <kuba@kernel.org>,
	andrew.gospodarek@broadcom.com, davem@davemloft.net,
	edumazet@google.com, jgg@ziepe.ca, leon@kernel.org,
	linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org,
	michael.chan@broadcom.com, netdev@vger.kernel.org,
	pabeni@redhat.com, selvin.xavier@broadcom.com,
	Leon Romanovsky <leonro@nvidia.com>
Subject: Re: [PATCH net-next v8 1/8] bnxt_en: Add auxiliary driver support
Date: Tue, 24 Jan 2023 08:38:25 +0100	[thread overview]
Message-ID: <Y8+K8fCJ03R4h1dF@kroah.com> (raw)
In-Reply-To: <CACZ4nhs2pSq73wEiySUgP8Gczmb=rz90pJOe747VtjKmm0yJbA@mail.gmail.com>

On Mon, Jan 23, 2023 at 11:07:07PM -0800, Ajit Khaparde wrote:
> On Mon, Jan 23, 2023 at 10:42 PM Greg Kroah-Hartman
> <gregkh@linuxfoundation.org> wrote:
> >
> > On Mon, Jan 23, 2023 at 10:33:05PM -0800, Jakub Kicinski wrote:
> > > On Thu, 19 Jan 2023 22:05:28 -0800 Ajit Khaparde wrote:
> > > > @@ -13212,6 +13214,7 @@ static void bnxt_remove_one(struct pci_dev *pdev)
> > > >     kfree(bp->rss_indir_tbl);
> > > >     bp->rss_indir_tbl = NULL;
> > > >     bnxt_free_port_stats(bp);
> > > > +   bnxt_aux_priv_free(bp);
> > > >     free_netdev(dev);
> > >
> > > You're still freeing the memory in which struct device sits regardless
> > > of its reference count.
> > >
> > > Greg, is it legal to call:
> > >
> > >       auxiliary_device_delete(adev);  // AKA device_del(&auxdev->dev);
> > >       auxiliary_device_uninit(adev);  // AKA put_device(&auxdev->dev);
> > >       free(adev);                     // frees struct device
> >
> > Ick, the aux device release callback should be doing the freeing of the
> > memory, you shouldn't ever have to free it "manually" like this.  To do
> > so would be a problem (i.e. the release callback would then free it
> > again, right?)
> Yikes!
> Thanks for the refresher.
> 
> >
> > > ? I tried to explain this three times, maybe there's some wait during
> > > device_del() I'm not seeing which makes this safe :S
> Apologies.
> I thought since the driver was allocating the memory, it had to free it.

Yes, you do, in the release function that will be called when the device
reference count is dropped to 0.

thanks,

greg k-h

  reply	other threads:[~2023-01-24  7:38 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-20  6:05 [PATCH net-next v8 0/8] Add Auxiliary driver support Ajit Khaparde
2023-01-20  6:05 ` [PATCH net-next v8 1/8] bnxt_en: Add auxiliary " Ajit Khaparde
2023-01-24  6:33   ` Jakub Kicinski
2023-01-24  6:42     ` Greg Kroah-Hartman
2023-01-24  7:07       ` Ajit Khaparde
2023-01-24  7:38         ` Greg Kroah-Hartman [this message]
2023-01-24  6:49     ` Leon Romanovsky
2023-01-24  7:08       ` Ajit Khaparde
2023-01-20  6:05 ` [PATCH net-next v8 2/8] RDMA/bnxt_re: Use auxiliary driver interface Ajit Khaparde
2023-01-20  6:05 ` [PATCH net-next v8 3/8] bnxt_en: Remove usage of ulp_id Ajit Khaparde
2023-01-20  6:05 ` [PATCH net-next v8 4/8] bnxt_en: Use direct API instead of indirection Ajit Khaparde
2023-01-20  6:05 ` [PATCH net-next v8 5/8] bnxt_en: Use auxiliary bus calls over proprietary calls Ajit Khaparde
2023-01-20  6:05 ` [PATCH net-next v8 6/8] bnxt_en: Remove struct bnxt access from RoCE driver Ajit Khaparde
2023-01-20  6:05 ` [PATCH net-next v8 7/8] RDMA/bnxt_re: Remove the sriov config callback Ajit Khaparde
2023-01-20  6:05 ` [PATCH net-next v8 8/8] bnxt_en: Remove runtime interrupt vector allocation Ajit Khaparde

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=Y8+K8fCJ03R4h1dF@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=ajit.khaparde@broadcom.com \
    --cc=andrew.gospodarek@broadcom.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=jgg@ziepe.ca \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=leonro@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=michael.chan@broadcom.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=selvin.xavier@broadcom.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).