diff mbox series

drm/nouveau/bios: fix incorrect kfree in platform_init

Message ID 1576900349-3786-1-git-send-email-wuxu.wu@huawei.com (mailing list archive)
State New, archived
Headers show
Series drm/nouveau/bios: fix incorrect kfree in platform_init | expand

Commit Message

wuxu.wu Dec. 21, 2019, 3:52 a.m. UTC
priv porinter could be free only when priv != null and priv->rom is null.

Signed-off-by: wuxu.wu <wuxu.wu@huawei.com>
---
 drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowpci.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowpci.c b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowpci.c
index 9b91da0..d776e01 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowpci.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowpci.c
@@ -70,8 +70,9 @@  pcirom_init(struct nvkm_bios *bios, const char *name)
 			    (priv->rom = pci_map_rom(pdev, &priv->size))) {
 				priv->pdev = pdev;
 				return priv;
+			} else {
+			    kfree(priv);
 			}
-			kfree(priv);
 		}
 		pci_disable_rom(pdev);
 	}