[Nouveau] [PATCH 2/3] drm/nouveau/led: guard against a division by 0

Martin Peres martin.peres at free.fr
Fri Sep 16 07:34:43 UTC 2016


Signed-off-by: Martin Peres <martin.peres at free.fr>
---
 drm/nouveau/nouveau_led.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drm/nouveau/nouveau_led.c b/drm/nouveau/nouveau_led.c
index 5e28b5f..1f731da 100644
--- a/drm/nouveau/nouveau_led.c
+++ b/drm/nouveau/nouveau_led.c
@@ -44,7 +44,10 @@ nouveau_led_get_brightness(struct led_classdev *led)
 	div =  nvif_rd32(device, 0x61c880) & 0x00ffffff;
 	duty = nvif_rd32(device, 0x61c884) & 0x00ffffff;
 
-	return duty * LED_FULL / div;
+	if (div > 0)
+		return duty * LED_FULL / div;
+	else
+		return 0;
 }
 
 static void
-- 
2.8.0



More information about the Nouveau mailing list