drm/nouveau/bios: check that fixed tvdac gpio data is valid before using it
authorBen Skeggs <bskeggs@redhat.com>
Wed, 12 Sep 2012 05:55:01 +0000 (15:55 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Wed, 3 Oct 2012 03:13:11 +0000 (13:13 +1000)
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drivers/gpu/drm/nouveau/core/subdev/bios/gpio.c

index 718267d84c7b7d69434aff712d0cdaf0b7eee2d2..1ae23b328bbd44b858e0e3d78fe84f2c6703d4b2 100644 (file)
@@ -100,13 +100,17 @@ dcb_gpio_parse(struct nouveau_bios *bios, int idx, u8 func, u8 line,
        /* DCB 2.2, fixed TVDAC GPIO data */
        if ((entry = dcb_table(bios, &ver, &hdr, &cnt, &len)) && ver >= 0x22) {
                if (func == DCB_GPIO_TVDAC0) {
-                       *gpio = (struct dcb_gpio_func) {
-                               .func = DCB_GPIO_TVDAC0,
-                               .line = nv_ro08(bios, entry - 4) >> 4,
-                               .log[0] = !!(nv_ro08(bios, entry - 5) & 2),
-                               .log[1] =  !(nv_ro08(bios, entry - 5) & 2),
-                       };
-                       return 0;
+                       u8 conf = nv_ro08(bios, entry - 5);
+                       u8 addr = nv_ro08(bios, entry - 4);
+                       if (conf & 0x01) {
+                               *gpio = (struct dcb_gpio_func) {
+                                       .func = DCB_GPIO_TVDAC0,
+                                       .line = addr >> 4,
+                                       .log[0] = !!(conf & 0x02),
+                                       .log[1] =  !(conf & 0x02),
+                               };
+                               return 0;
+                       }
                }
        }