device: call nvkm_device_fini if nvkm_device_init fails
PATCH 1/1 device: call nvkm_device_fini if nvkm_device_init fails
nvkm_device_fini is never called if a failure occurs in nvkm_device_init, even when unloading the module. This can lead to a resources leak (one example is the Tegra interrupt which would never be freed in that case). Fix this by calling nvkm_device_fini in nvkm_device_init's failure path.
--- drm/nouveau/nvkm/engine/device/base.c | 2 ++ 1 file changed, 2 insertions(+)
drm/nouveau/nvkm/engine/device/base.c +2 -0
@@ -2261,6 +2261,8 @@ fail_subdev: }while (--i >=0 ); fail: +nvkm_device_fini (device, false); +nvdev_error (device,"init failed with %d\n" , ret);return ret; }
Signature · 6 lines
2.7.0 _______________________________________________ Nouveau mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/nouveau
A message that is not in the archive (sent off-list or not yet received): 1453715064-14160-1-git-send-email-acourbot-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org
PATCH 1/1 device/tegra: fix uninitialized IRQ number
nvkm_device_tegra_new initializes the irq member of the Tegra device to -1 in order to signal that it is uninitialized. However, nvkm_device_tegra_fini tests it against 0 to check whether an IRQ has been allocated or not. This leads to free_irq being called on -1 during device initialization.
--- drm/nouveau/nvkm/engine/device/tegra.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drm/nouveau/nvkm/engine/device/tegra.c +2 -2
@@ -195,9 +195,9 @@ static void nvkm_device_tegra_fini(struct nvkm_device *device, bool suspend) {struct nvkm_device_tegra *tdev =nvkm_device_tegra (device); -if (tdev->irq) { +if (tdev->irq !=-1 ) {free_irq (tdev->irq, tdev); - tdev->irq =0 ; + tdev->irq =-1 ; }; }
Signature · 6 lines
2.7.0 _______________________________________________ Nouveau mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/nouveau
A message that is not in the archive (sent off-list or not yet received): 1453715064-14160-2-git-send-email-acourbot-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org
Re: [PATCH] device/tegra: fix uninitialized IRQ number
Am Montag, den 25.01.2016, 18:44 +0900 schrieb Alexandre Courbot:
Quoted 7 lines
nvkm_device_tegra_newinitializes the irq member of the Tegra device to -1 in order to signal that it is uninitialized. However,nvkm_device_tegra_finitests it against 0 to check whether an IRQ has been allocated or not. This leads tofree_irqbeing called on -1 during
device initialization.
The convention in other parts of the Linux kernel is that IRQ number 0 means unallocated/invalid IRQ. So I think it is the initialization to -1 that should be fixed instead.
Quoted 21 lines
Signed-off-by Alexandre Courbot <[email protected]>---
drm/nouveau/nvkm/engine/device/tegra.c | 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)drm/nouveau/nvkm/engine/device/tegra.c +2
-2@@ -195,9 +195,9 @@ static void nvkm_device_tegra_fini(struct nvkm_device *device, bool suspend) { struct nvkm_device_tegra *tdev = nvkm_device_tegra(device); -if (tdev->irq) { +if (tdev->irq !=-1 ) { free_irq(tdev->irq, tdev); - tdev->irq =0 ; + tdev->irq =-1 ; }; }
Quoted 1 line
_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH] device/tegra: fix uninitialized IRQ number
Quoted 11 lines · Lucas Stach
Am Montag, den 25.01.2016, 18:44 +0900 schrieb Alexandre Courbot:
Quoted 7 lines
nvkm_device_tegra_newinitializes the irq member of the Tegra device to -1 in order to signal that it is uninitialized. However,nvkm_device_tegra_finitests it against 0 to check whether an IRQ has been allocated or not. This leads tofree_irqbeing called on -1 during
device initialization.The convention in other parts of the Linux kernel is that IRQ number 0 means unallocated/invalid IRQ. So I think it is the initialization to -1 that should be fixed instead.
Uh, that sounds unsafe. Thanks for spotting this, will resend.
_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau
A message that is not in the archive (sent off-list or not yet received): CAAVeFu+U3maa=o_T+=aG-D1snzLZJcUMSW+BaTT=RWBwfq0OpQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
PATCH v2 1/1 device/tegra: fix uninitialized IRQ number
nvkm_device_tegra_new initializes the irq member of the Tegra device to -1 in order to signal that it is uninitialized. However, nvkm_device_tegra_fini tests it against 0 to check whether an IRQ has been allocated or not. This leads to free_irq being called on -1 during device initialization.
Fix this by using 0 as the uninitialized value everywhere.
---
v2: use 0 as the uninitialized value, as suggested by Lucas.
drm/nouveau/nvkm/engine/device/tegra.c | 1 - 1 file changed, 1 deletion(-)
drm/nouveau/nvkm/engine/device/tegra.c +0 -1
@@ -255,7 +255,6 @@ nvkm_device_tegra_new(const struct nvkm_device_tegra_func *func, *pdevice = &tdev->device; tdev->func = func; tdev->pdev = pdev; - tdev->irq =-1 ; tdev->vdd =devm_regulator_get (&pdev->dev,"vdd" );if (IS_ERR (tdev->vdd))
Signature · 6 lines
2.7.0 _______________________________________________ Nouveau mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/nouveau
Should these get back-ported to any released kernels?
Quoted 27 lines · Alexandre Courbot
nvkm_device_finiis never called if a failure occurs innvkm_device_init, even when unloading the module. This can lead to a resources leak (one example is the Tegra interrupt which would never be freed in that case). Fix this by callingnvkm_device_finiin nvkm_device_init's failure path.Signed-off-by Alexandre Courbot <[email protected]>--- drm/nouveau/nvkm/engine/device/base.c | 2 ++ 1 file changed, 2 insertions(+)drm/nouveau/nvkm/engine/device/base.c +2
-1@@ -2261,6 +2261,8 @@ fail_subdev: }while (--i >=0 ); fail: +nvkm_device_fini (device, false); +nvdev_error (device,"init failed with %d\n" , ret);return ret; } --2.7.0
Quoted 4 lines
_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau
_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau
A message that is not in the archive (sent off-list or not yet received): CAKb7UvgrPC9=hJPyRMULYjwsrNU+6oopgfTkuT8c2pUNc1PRaQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Quoted 1 line · Ilia Mirkin
Should these get back-ported to any released kernels?
Probably ok not to, I found these while testing the error paths for secure boot.
Quoted 29 lines · Alexandre Courbot
Quoted 27 lines
nvkm_device_finiis never called if a failure occurs innvkm_device_init, even when unloading the module. This can lead to a resources leak (one example is the Tegra interrupt which would never be freed in that case). Fix this by callingnvkm_device_finiin nvkm_device_init's failure path.Signed-off-by Alexandre Courbot <[email protected]>--- drm/nouveau/nvkm/engine/device/base.c | 2 ++ 1 file changed, 2 insertions(+)drm/nouveau/nvkm/engine/device/base.c +2
-1@@ -2261,6 +2261,8 @@ fail_subdev: }while (--i >=0 ); fail: +nvkm_device_fini (device, false); +nvdev_error (device,"init failed with %d\n" , ret);return ret; } --2.7.0
Quoted 8 lines
Quoted 4 lines
_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau
_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau