lkml.org 
[lkml]   [2013]   [Jan]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH v8 04/22] PCI: Fix a device reference count leakage issue in pci_dev_present()
    Date
    From: Jiang Liu <jiang.liu@huawei.com>

    Function pci_get_dev_by_id() will hold a reference count on the pci device
    returned, so pci_dev_present() should release the corresponding reference
    count to avoid memory leakage.

    Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
    ---
    drivers/pci/search.c | 10 +++++-----
    1 file changed, 5 insertions(+), 5 deletions(-)

    diff --git a/drivers/pci/search.c b/drivers/pci/search.c
    index bf969ba..d0627fa 100644
    --- a/drivers/pci/search.c
    +++ b/drivers/pci/search.c
    @@ -319,13 +319,13 @@ int pci_dev_present(const struct pci_device_id *ids)
    WARN_ON(in_interrupt());
    while (ids->vendor || ids->subvendor || ids->class_mask) {
    found = pci_get_dev_by_id(ids, NULL);
    - if (found)
    - goto exit;
    + if (found) {
    + pci_dev_put(found);
    + return 1;
    + }
    ids++;
    }
    -exit:
    - if (found)
    - return 1;
    +
    return 0;
    }
    EXPORT_SYMBOL(pci_dev_present);
    --
    1.7.10.4


    \
     
     \ /
      Last update: 2013-01-12 00:41    [W:4.225 / U:0.112 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site