Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

omapfb: panel-sharp-ls037v7dw01: fix check of gpio_to_desc() return value

The change fixes a check of gpio_to_desc() return value, the function
returns either a valid pointer to struct gpio_desc or NULL, this makes
IS_ERR() check invalid and may lead to a NULL pointer dereference in
runtime.

Signed-off-by: Vladimir Zapolskiy <vz@mleia.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>

authored by

Vladimir Zapolskiy and committed by
Tomi Valkeinen
4dacad61 f36fdacc

+4 -8
+4 -8
drivers/video/fbdev/omap2/omapfb/displays/panel-sharp-ls037v7dw01.c
··· 200 200 static int sharp_ls_get_gpio(struct device *dev, int gpio, unsigned long flags, 201 201 char *desc, struct gpio_desc **gpiod) 202 202 { 203 - struct gpio_desc *gd; 204 203 int r; 205 204 206 - *gpiod = NULL; 207 - 208 205 r = devm_gpio_request_one(dev, gpio, flags, desc); 209 - if (r) 206 + if (r) { 207 + *gpiod = NULL; 210 208 return r == -ENOENT ? 0 : r; 209 + } 211 210 212 - gd = gpio_to_desc(gpio); 213 - if (IS_ERR(gd)) 214 - return PTR_ERR(gd) == -ENOENT ? 0 : PTR_ERR(gd); 211 + *gpiod = gpio_to_desc(gpio); 215 212 216 - *gpiod = gd; 217 213 return 0; 218 214 } 219 215