Bug 114711 - ubsan: "shift exponent 32 is too large" nouveau/nvkm/subdev/gpio/base.c:167:16
diff mbox

Message ID 20160404110222.GA8011@junk-foo
State New
Headers show

Commit Message

Navin P.S April 4, 2016, 11:02 a.m. UTC
Hi,

Please find the below patch that fixes "Bug 114711 - ubsan: "shift exponent 32 is too large" in drivers/gpu/drm/nouveau/nvkm/subdev/gpio/base.c:167:16"
At runtime we shift 1 by 32 which is not correct since 1 is a signed integer. I make it unsigned and the maximum we shift is 32.


---
 drivers/gpu/drm/nouveau/nvkm/subdev/gpio/base.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch
diff mbox

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/gpio/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/gpio/base.c
index d45ec99..cd28376 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/gpio/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/gpio/base.c
@@ -164,7 +164,7 @@  static int
 nvkm_gpio_fini(struct nvkm_subdev *subdev, bool suspend)
 {
 	struct nvkm_gpio *gpio = nvkm_gpio(subdev);
-	u32 mask = (1 << gpio->func->lines) - 1;
+	u32 mask = (1U << (min(gpio->func->lines, 32))) - 1;
 
 	gpio->func->intr_mask(gpio, NVKM_GPIO_TOGGLED, mask, 0);
 	gpio->func->intr_stat(gpio, &mask, &mask);