[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <eibktb7odiqdmcyv5cumc7h74ajjyv6ojn3felasxzcl2d7w2u@5nz7ybmldf35>
Date: Thu, 2 Oct 2025 02:04:41 +0200
From: Andi Shyti <andi.shyti@...nel.org>
To: Ma Ke <make24@...as.ac.cn>
Cc: syniurge@...il.com, shyam-sundar.s-k@....com, wsa@...nel.org,
linux-i2c@...r.kernel.org, linux-kernel@...r.kernel.org, akpm@...ux-foundation.org,
stable@...r.kernel.org
Subject: Re: [PATCH v2] i2c: fix reference leak in MP2 PCI device
Hi again,
On Thu, Oct 02, 2025 at 01:56:30AM +0200, Andi Shyti wrote:
> Hi,
>
> > diff --git a/drivers/i2c/busses/i2c-amd-mp2-pci.c b/drivers/i2c/busses/i2c-amd-mp2-pci.c
> > index ef7370d3dbea..60edbabc2986 100644
> > --- a/drivers/i2c/busses/i2c-amd-mp2-pci.c
> > +++ b/drivers/i2c/busses/i2c-amd-mp2-pci.c
> > @@ -458,13 +458,16 @@ struct amd_mp2_dev *amd_mp2_find_device(void)
> > {
> > struct device *dev;
> > struct pci_dev *pci_dev;
> > + struct amd_mp2_dev *mp2_dev;
> >
> > dev = driver_find_next_device(&amd_mp2_pci_driver.driver, NULL);
> > if (!dev)
> > return NULL;
> >
> > pci_dev = to_pci_dev(dev);
> > - return (struct amd_mp2_dev *)pci_get_drvdata(pci_dev);
> > + mp2_dev = (struct amd_mp2_dev *)pci_get_drvdata(pci_dev);
> > + put_device(dev);
> > + return mp2_dev;
>
> the patch is good, but I don't think you need to declare mp2_dev
> because to_pci_dev(dev) should work even without hodling the
> reference of dev.
>
> I also have to agree with Markus that something like:
>
> struct device *dev __free(put_device) = ...; /* it can also be NULL */
sorry, please ignore this last comment, because if !dev we
shouldn't call put_device().
Andi
Powered by blists - more mailing lists