From: Krzysztof Kozlowski <krzk@kernel.org>
To: Jakub Kicinski <kuba@kernel.org>,
Geert Uytterhoeven <geert@linux-m68k.org>,
"David S. Miller" <davem@davemloft.net>,
Mark Brown <broonie@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Paolo Abeni <pabeni@redhat.com>
Cc: Daniel Mack <daniel@zonque.org>,
Haojian Zhuang <haojian.zhuang@gmail.com>,
Robert Jarzmik <robert.jarzmik@free.fr>,
linux-arm-kernel@lists.infradead.org, linux-spi@vger.kernel.org,
linux-kernel@vger.kernel.org, opensource.kernel@vivo.com,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Yang Ruibin <11162571@vivo.com>
Subject: Re: [PATCH v2] drivers: spi: Insert the missing pci_dev_put()before return
Date: Fri, 30 Aug 2024 19:10:20 +0200 [thread overview]
Message-ID: <4e2ad62b-b11e-40db-9cd9-a26f7642c735@kernel.org> (raw)
In-Reply-To: <CAMuHMdWNjo69_W6f+R9QJJOf8uF0htg2XazeS-yjugJv3UM+kg@mail.gmail.com>
On 30/08/2024 10:55, Geert Uytterhoeven wrote:
> Hi Yang,
>
> On Thu, Aug 29, 2024 at 5:35 AM Yang Ruibin <11162571@vivo.com> wrote:
>> Increase the reference count by calling pci_get_slot(), and remember to
>> decrement the reference count by calling pci_dev_put().
>>
>> Signed-off-by: Yang Ruibin <11162571@vivo.com>
>
> Thanks for your patch, which is now commit 8a0ec8c2d736961f ("spi:
> Insert the missing pci_dev_put()before return") in spi/for-next.
>
>> --- a/drivers/spi/spi-pxa2xx-pci.c
>> +++ b/drivers/spi/spi-pxa2xx-pci.c
>> @@ -146,8 +146,10 @@ static int lpss_spi_setup(struct pci_dev *dev, struct pxa2xx_spi_controller *c)
>> c->num_chipselect = 1;
>>
>> ret = pxa2xx_spi_pci_clk_register(dev, ssp, 50000000);
>> - if (ret)
>> + if (ret) {
>> + pci_dev_put(dma_dev);
>
> dma_dev is still uninitialized at this point.
>
>> return ret;
>> + }
>>
>> dma_dev = pci_get_slot(dev->bus, PCI_DEVFN(PCI_SLOT(dev->devfn), 0));
>
> dma_dev is initialized only here...
>
>> ret = devm_add_action_or_reset(&dev->dev, lpss_dma_put_device, dma_dev);
>
> ... and freed automatically by lpss_dma_put_device() in case of
> any later failures since commit 609d7ffdc42199a0 ("spi: pxa2xx-pci:
> Balance reference count for PCI DMA device") in v5.18.
>
>> @@ -222,8 +224,10 @@ static int mrfld_spi_setup(struct pci_dev *dev, struct pxa2xx_spi_controller *c)
>> }
>>
>> ret = pxa2xx_spi_pci_clk_register(dev, ssp, 25000000);
>> - if (ret)
>> + if (ret) {
>> + pci_dev_put(dma_dev);
>> return ret;
>> + }
>>
>> dma_dev = pci_get_slot(dev->bus, PCI_DEVFN(21, 0));
>> ret = devm_add_action_or_reset(&dev->dev, lpss_dma_put_device, dma_dev);
>
> Likewise.
>
> Hence this patch is not needed, and introduced two bugs.
Cc Greg, Jakub, David and Paolo,
It seems Vivo (at least two persons from vivo.com) is sending patches
generated through some sort of automation without really knowing what
they were doing. All of the patches look like innocent
cleanups/simplifications/fixes, but they do more.
This patch here looks like introducing two bugs.
These patches:
1. https://lore.kernel.org/all/20240830033251.232992-1-yujiaoliang@vivo.com/
2. https://lore.kernel.org/all/20240828122650.1324246-1-11162571@vivo.com/
(I sent a revert for this)
3. https://lore.kernel.org/all/20240829072016.2329466-1-11162571@vivo.com/
and probably more...
introduce dev_err_probe() outside of probe path which is not desired,
because it marks a probed (working) device as deferred.
The patches look trivial and/or helpful, so people tend to accept them
through default trust.
I kindly suggest reverse - do not trust them by default and instead do a
thorough review before accepting any cleanup/trivial patch from @vivo.com.
Best regards,
Krzysztof
next prev parent reply other threads:[~2024-08-30 17:11 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-29 3:35 [PATCH v2] drivers: spi: Insert the missing pci_dev_put()before return Yang Ruibin
2024-08-29 17:38 ` Mark Brown
2024-08-30 8:55 ` Geert Uytterhoeven
2024-08-30 17:10 ` Krzysztof Kozlowski [this message]
2024-08-30 17:49 ` Jakub Kicinski
2024-09-02 7:15 ` Yuesong Li
2024-09-03 6:29 ` Greg Kroah-Hartman
2024-08-30 19:12 ` Andy Shevchenko
2024-08-30 19:56 ` Mark Brown
2024-09-02 10:21 ` Andy Shevchenko
2024-08-30 19:57 ` Mark Brown
2024-08-30 22:23 ` Nathan Chancellor
2024-09-02 11:48 ` Mark Brown
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=4e2ad62b-b11e-40db-9cd9-a26f7642c735@kernel.org \
--to=krzk@kernel.org \
--cc=11162571@vivo.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=broonie@kernel.org \
--cc=daniel@zonque.org \
--cc=davem@davemloft.net \
--cc=geert@linux-m68k.org \
--cc=gregkh@linuxfoundation.org \
--cc=haojian.zhuang@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=opensource.kernel@vivo.com \
--cc=pabeni@redhat.com \
--cc=robert.jarzmik@free.fr \
/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).