diff mbox series

PCI: fix a scheduling in atomic bug

Message ID 20210812070004.GC31863@kili (mailing list archive)
State Accepted
Delegated to: Bjorn Helgaas
Headers show
Series PCI: fix a scheduling in atomic bug | expand

Commit Message

Dan Carpenter Aug. 12, 2021, 7 a.m. UTC
This function is often called with a spinlock held so the allocation has
to be atomic.  The call tree is:

pci_specified_resource_alignment() <-- takes spin_lock();
 -> pci_dev_str_match()
    -> pci_dev_str_match_path()

Fixes: 07d8d7e57c28 ("PCI: Make specifying PCI devices in kernel parameters reusable")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/pci/pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Logan Gunthorpe Aug. 12, 2021, 3:19 p.m. UTC | #1
On 2021-08-12 1:00 a.m., Dan Carpenter wrote:
> This function is often called with a spinlock held so the allocation has
> to be atomic.  The call tree is:
> 
> pci_specified_resource_alignment() <-- takes spin_lock();
>  -> pci_dev_str_match()
>     -> pci_dev_str_match_path()
> 
> Fixes: 07d8d7e57c28 ("PCI: Make specifying PCI devices in kernel parameters reusable")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

This looks good to me, but I think the fixes tag is wrong.
pci_dev_str_match_path() was introduced in this patch:

Fixes: 45db33709ccc ("PCI: Allow specifying devices using a base bus and
path of devfns")

Reviewed-by: Logan Gunthorpe <logang@deltatee.com>

Thanks,

Logan
Bjorn Helgaas Aug. 12, 2021, 7:16 p.m. UTC | #2
On Thu, Aug 12, 2021 at 10:00:04AM +0300, Dan Carpenter wrote:
> This function is often called with a spinlock held so the allocation has
> to be atomic.  The call tree is:
> 
> pci_specified_resource_alignment() <-- takes spin_lock();
>  -> pci_dev_str_match()
>     -> pci_dev_str_match_path()
> 
> Fixes: 07d8d7e57c28 ("PCI: Make specifying PCI devices in kernel parameters reusable")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Applied with Logan's Reviewed-by and Fixes: update to pci/misc for
v5.15, thanks!

> ---
>  drivers/pci/pci.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index 6714c58ce321..71baf5ff48fc 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -269,7 +269,7 @@ static int pci_dev_str_match_path(struct pci_dev *dev, const char *path,
>  
>  	*endptr = strchrnul(path, ';');
>  
> -	wpath = kmemdup_nul(path, *endptr - path, GFP_KERNEL);
> +	wpath = kmemdup_nul(path, *endptr - path, GFP_ATOMIC);
>  	if (!wpath)
>  		return -ENOMEM;
>  
> -- 
> 2.20.1
>
Dan Carpenter Aug. 13, 2021, 7:27 a.m. UTC | #3
On Thu, Aug 12, 2021 at 09:19:42AM -0600, Logan Gunthorpe wrote:
> 
> 
> 
> On 2021-08-12 1:00 a.m., Dan Carpenter wrote:
> > This function is often called with a spinlock held so the allocation has
> > to be atomic.  The call tree is:
> > 
> > pci_specified_resource_alignment() <-- takes spin_lock();
> >  -> pci_dev_str_match()
> >     -> pci_dev_str_match_path()
> > 
> > Fixes: 07d8d7e57c28 ("PCI: Make specifying PCI devices in kernel parameters reusable")
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> This looks good to me, but I think the fixes tag is wrong.
> pci_dev_str_match_path() was introduced in this patch:
> 
> Fixes: 45db33709ccc ("PCI: Allow specifying devices using a base bus and
> path of devfns")

Yeah.  You're right.  Thanks.  Thanks, Bjorn for fixing this.

regards,
dan carpenter
diff mbox series

Patch

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 6714c58ce321..71baf5ff48fc 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -269,7 +269,7 @@  static int pci_dev_str_match_path(struct pci_dev *dev, const char *path,
 
 	*endptr = strchrnul(path, ';');
 
-	wpath = kmemdup_nul(path, *endptr - path, GFP_KERNEL);
+	wpath = kmemdup_nul(path, *endptr - path, GFP_ATOMIC);
 	if (!wpath)
 		return -ENOMEM;