Skip to content

Commit

Permalink
mmc: sdhci-pci: Fix possible memory leak caused by missing pci_dev_put()
Browse files Browse the repository at this point in the history
commit 222cfa0 upstream.

pci_get_device() will increase the reference count for the returned
pci_dev. We need to use pci_dev_put() to decrease the reference count
before amd_probe() returns. There is no problem for the 'smbus_dev ==
NULL' branch because pci_dev_put() can also handle the NULL input
parameter case.

Fixes: 659c9bc ("mmc: sdhci-pci: Build o2micro support in the same module")
Signed-off-by: Xiongfeng Wang <wangxiongfeng2@huawei.com>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20221114083100.149200-1-wangxiongfeng2@huawei.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
fenghusthu authored and gregkh committed Nov 26, 2022
1 parent 4039c60 commit 35bca18
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/mmc/host/sdhci-pci-core.c
Expand Up @@ -1728,6 +1728,8 @@ static int amd_probe(struct sdhci_pci_chip *chip)
}
}

pci_dev_put(smbus_dev);

if (gen == AMD_CHIPSET_BEFORE_ML || gen == AMD_CHIPSET_CZ)
chip->quirks2 |= SDHCI_QUIRK2_CLEAR_TRANSFERMODE_REG_BEFORE_CMD;

Expand Down

0 comments on commit 35bca18

Please sign in to comment.