Skip to contentSkip to conversation

PCI: pciehp: Always protect pciehp_disable_slot() with hotplug mutex

PATCH In review Guenter Roeck 3 participants 4 messages Nov 1, 2015 – Nov 25, 2015 1 message not in the archive PCI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PCI: pciehp: Always protect pciehp_disable_slot() with hotplug mutex

When called from pciehp_sysfs_disable_slot(), the call to pciehp_disable_slot() was not protected by the hotplug mutex.

---
 drivers/pci/hotplug/pciehp_ctrl.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/pci/hotplug/pciehp_ctrl.c +2 -0
index 4c8f4cde6854..880978b6d534 100644
@@ -511,7 +511,9 @@ int pciehp_sysfs_disable_slot(struct slot *p_slot)
 	case STATIC_STATE:
 		p_slot->state = POWEROFF_STATE;
 		mutex_unlock(&p_slot->lock);
+		mutex_lock(&p_slot->hotplug_lock);
 		retval = pciehp_disable_slot(p_slot);
+		mutex_unlock(&p_slot->hotplug_lock);
 		mutex_lock(&p_slot->lock);
 		p_slot->state = STATIC_STATE;
 		break;
Signature · 1 line
2.1.4
Reviewed-by on v1 1/1
#1 lore raw

Geez... I wonder how did I miss it. Thanks for fixing this. Looks good to me.

Quoted 26 lines · Guenter Roeck

When called from pciehp_sysfs_disable_slot(), the call to pciehp_disable_slot() was not protected by the hotplug mutex.

---
 drivers/pci/hotplug/pciehp_ctrl.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/pci/hotplug/pciehp_ctrl.c +2 -1
index 4c8f4cde6854..880978b6d534 100644
@@ -511,7 +511,9 @@ int pciehp_sysfs_disable_slot(struct slot *p_slot)
        case STATIC_STATE:
                p_slot->state = POWEROFF_STATE;
                mutex_unlock(&p_slot->lock);
+               mutex_lock(&p_slot->hotplug_lock);
                retval = pciehp_disable_slot(p_slot);
+               mutex_unlock(&p_slot->hotplug_lock);
                mutex_lock(&p_slot->lock);
                p_slot->state = STATIC_STATE;
                break;
--

2.1.4

A message that is not in the archive (sent off-list or not yet received): CAA93t1o1tFvZDiBNfU62q+sfiykVxKCAs_ZWJ-uDjyEWaLEwoQ@mail.gmail.com

#3 lore raw
Quoted 3 lines · Rajat Jain

Geez... I wonder how did I miss it. Thanks for fixing this. Looks good to me.

Hi Rajat,

easy to miss. I only found it accidentally.

Thanks a lot for the review!

Guenter

Quoted 31 lines
Reviewed-by Rajat Jain <[email protected] <mailto:[email protected]>>

On Sun, Nov 1, 2015 at 1:58 PM, Guenter Roeck <[email protected] <mailto:[email protected]>> wrote:

    When called from pciehp_sysfs_disable_slot(), the call to
    pciehp_disable_slot() was not protected by the hotplug mutex.

    Cc: Rajat Jain <[email protected] <mailto:[email protected]>>
    Signed-off-by: Guenter Roeck <[email protected] <mailto:[email protected]>>
    ---
      drivers/pci/hotplug/pciehp_ctrl.c | 2 ++
      1 file changed, 2 insertions(+)

    diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c
    index 4c8f4cde6854..880978b6d534 100644
    --- a/drivers/pci/hotplug/pciehp_ctrl.c
    +++ b/drivers/pci/hotplug/pciehp_ctrl.c
    @@ -511,7 +511,9 @@ int pciehp_sysfs_disable_slot(struct slot *p_slot)
             case STATIC_STATE:
                     p_slot->state = POWEROFF_STATE;
                     mutex_unlock(&p_slot->lock);
    +               mutex_lock(&p_slot->hotplug_lock);
                     retval = pciehp_disable_slot(p_slot);
    +               mutex_unlock(&p_slot->hotplug_lock);
                     mutex_lock(&p_slot->lock);
                     p_slot->state = STATIC_STATE;
                     break;
    --
    2.1.4
#4 lore raw
In reply to Guenter Roeck
Quoted 5 lines · Guenter Roeck

When called from pciehp_sysfs_disable_slot(), the call to pciehp_disable_slot() was not protected by the hotplug mutex.

Applied with Rajat's Reviewed-by to pci/hotplug for v4.5, thanks!

Quoted 25 lines
---
 drivers/pci/hotplug/pciehp_ctrl.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/pci/hotplug/pciehp_ctrl.c +2 -0
index 4c8f4cde6854..880978b6d534 100644
@@ -511,7 +511,9 @@ int pciehp_sysfs_disable_slot(struct slot *p_slot)
 	case STATIC_STATE:
 		p_slot->state = POWEROFF_STATE;
 		mutex_unlock(&p_slot->lock);
+		mutex_lock(&p_slot->hotplug_lock);
 		retval = pciehp_disable_slot(p_slot);
+		mutex_unlock(&p_slot->hotplug_lock);
 		mutex_lock(&p_slot->lock);
 		p_slot->state = STATIC_STATE;
 		break;
Signature · 6 lines
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html