Netdev List
 help / color / mirror / Atom feed
From: Ratheesh Kannoth <rkannoth@marvell.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: Yuho Choi <dbgh9129@gmail.com>,
	Sunil Goutham <sgoutham@marvell.com>,
	"Linu Cherian" <lcherian@marvell.com>,
	Geetha sowjanya <gakula@marvell.com>,
	hariprasad <hkelam@marvell.com>,
	Subbaraya Sundeep <sbhatta@marvell.com>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Paolo Abeni <pabeni@redhat.com>, <netdev@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, <nshettyj@marvell.com>
Subject: Re: [PATCH net-next v2] octeontx2-af: Fix PCI device reference leaks in debugfs
Date: Thu, 11 Jun 2026 07:51:08 +0530	[thread overview]
Message-ID: <aioblJqQctA_9U8y@rkannoth-OptiPlex-7090> (raw)
In-Reply-To: <20260610083544.0da95356@kernel.org>

On 2026-06-10 at 21:05:44, Jakub Kicinski (kuba@kernel.org) wrote:
> On Mon,  8 Jun 2026 12:55:46 -0400 Yuho Choi wrote:
> > cgx_print_stats(), cgx_print_dmac_flt(), and cgx_print_fwdata()
> > look up the RVU AF device with pci_get_device() and pass the returned
> > pointer directly to pci_get_drvdata().  pci_get_device() returns a PCI
> > device with an elevated reference count, so the lookup reference is
> > leaked on every debugfs read.
> >
> > Store the returned PCI device pointer, check it before reading driver
> > data, and release the lookup reference after pci_get_drvdata(). In
> > cgx_print_dmac_flt(), release the AF lookup reference before reusing
> > pdev for pci_get_domain_bus_and_slot().
> >
> > Fixes: f967488d095e ("octeontx2-af: Add per CGX port level NIX Rx/Tx counters")
> > Fixes: dbc52debf95f ("octeontx2-af: Debugfs support for DMAC filters")
> > Fixes: 49f02e6877d1 ("Octeontx2-af: Debugfs support for firmware data")
> > Signed-off-by: Yuho Choi <dbgh9129@gmail.com>
>
> Marvell, please review patches from external contributors promptly.
>
> Review question sort of based on a Sashiko comment - this is part of
> the rvu device driver, AFAIU, does anything prevent the AF from getting
> removed (via sysfs for instance) while this code is using its priv?

RVU AF driver's teardown sequence prevents the race here. In
rvu_remove(), the very first call is rvu_dbg_exit(rvu),
which calls debugfs_remove_recursive() on the debugfs root.
ASFAIK, debugfs_remove_recursive() will block until all active
readers (i.e., any in-progress seq_file read callbacks like
cgx_print_stats(), cgx_print_dmac_flt(), and
cgx_print_fwdata()) have completed before the removal
proceeds. Only after rvu_dbg_exit() returns does
rvu_remove() proceed to free the rvu structure.

A better approach would be to pass the rvu object(rvu structure has pdev field) while
creating the debugfs file itself, e.g.:

  RVU_DEBUG_SEQ_FOPS(cgx_dmac_flt, cgx_dmac_flt_display, s/NULL/rvu);

This would eliminate the pci_get_device() lookup entirely. We
will post this as a code clean-up patch to net-next.

  reply	other threads:[~2026-06-11  2:21 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-08 16:55 [PATCH net-next v2] octeontx2-af: Fix PCI device reference leaks in debugfs Yuho Choi
2026-06-10 15:35 ` Jakub Kicinski
2026-06-11  2:21   ` Ratheesh Kannoth [this message]
2026-06-11 17:45     ` Jakub Kicinski
2026-06-11 19:03       ` 최유호
2026-06-12  1:58         ` Ratheesh Kannoth
2026-06-12 15:35           ` 최유호
2026-06-12  1:49       ` Ratheesh Kannoth

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=aioblJqQctA_9U8y@rkannoth-OptiPlex-7090 \
    --to=rkannoth@marvell.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=dbgh9129@gmail.com \
    --cc=edumazet@google.com \
    --cc=gakula@marvell.com \
    --cc=hkelam@marvell.com \
    --cc=kuba@kernel.org \
    --cc=lcherian@marvell.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=nshettyj@marvell.com \
    --cc=pabeni@redhat.com \
    --cc=sbhatta@marvell.com \
    --cc=sgoutham@marvell.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