[PATCH 2/5] drivers/macintosh/via-pmu.c: Add missing pci_dev_put - Kernel

This is a discussion on [PATCH 2/5] drivers/macintosh/via-pmu.c: Add missing pci_dev_put - Kernel ; From: Julia Lawall There should be a pci_dev_put when breaking out of a loop that iterates over calls to pci_get_device and similar functions. In this case, the return under the #else case of #ifdef HACKED_PCI_SAVE should have a pci_dev_put, just ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: [PATCH 2/5] drivers/macintosh/via-pmu.c: Add missing pci_dev_put

  1. [PATCH 2/5] drivers/macintosh/via-pmu.c: Add missing pci_dev_put

    From: Julia Lawall

    There should be a pci_dev_put when breaking out of a loop that iterates
    over calls to pci_get_device and similar functions.

    In this case, the return under the #else case of #ifdef HACKED_PCI_SAVE
    should have a pci_dev_put, just as the return in the case where
    HACKED_PCI_SAVE is true does.

    This was fixed using the following semantic patch.

    //
    @@
    type T;
    identifier d;
    expression e;
    @@

    T *d;
    ....
    while ((d = \(pci_get_device\|pci_get_device_reverse\|pci_get_ subsys\|pci_get_class\)(..., d)) != NULL)
    {... when != pci_dev_put(d)
    when != e = d
    (
    return d;
    |
    + pci_dev_put(d);
    ? return ...;
    )
    ....}
    //


    Signed-off-by: Julia Lawall
    ---

    diff -u -p a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c
    --- a/drivers/macintosh/via-pmu.c 2007-11-18 20:43:10.000000000 +0100
    +++ b/drivers/macintosh/via-pmu.c 2007-11-19 08:16:44.000000000 +0100
    @@ -1896,8 +1896,10 @@ pbook_pci_restore(void)
    pci_write_config_dword(pd, i<<4, ps->config[i]);
    pci_write_config_dword(pd, 4, ps->config[1]);
    #else
    - if (npci-- == 0)
    + if (npci-- == 0) {
    + pci_dev_put(pd);
    return;
    + }
    ps++;
    if (ps->command == 0)
    continue;
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  2. Re: [PATCH 2/5] drivers/macintosh/via-pmu.c: Add missing pci_dev_put


    On Mon, 2007-11-19 at 09:03 +0100, Julia Lawall wrote:
    > From: Julia Lawall
    >
    > There should be a pci_dev_put when breaking out of a loop that iterates
    > over calls to pci_get_device and similar functions.
    >
    > In this case, the return under the #else case of #ifdef HACKED_PCI_SAVE
    > should have a pci_dev_put, just as the return in the case where
    > HACKED_PCI_SAVE is true does.
    >
    > This was fixed using the following semantic patch.


    I think most of that code is no longer necessary (and the lack of
    pci_dev_put() is mostly due to the fact that this code long predates the
    existence of pci_dev_put :-)

    I want to try out without that PCI save/restore code on a couple of old
    machines see if we can just remove the whole thing.

    Ben.


    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

+ Reply to Thread