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

fbdev: pxafb: use devm_kmemdup*()

Convert to use devm_kmemdup() and devm_kmemdup_array() which are
more robust.

Signed-off-by: Raag Jadav <raag.jadav@intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Helge Deller <deller@gmx.de>

authored by

Raag Jadav and committed by
Helge Deller
b347f457 892c788d

+9 -14
+9 -14
drivers/video/fbdev/pxafb.c
··· 2233 2233 { 2234 2234 struct pxafb_info *fbi; 2235 2235 struct pxafb_mach_info *inf, *pdata; 2236 - int i, irq, ret; 2236 + int irq, ret; 2237 2237 2238 2238 dev_dbg(&dev->dev, "pxafb_probe\n"); 2239 2239 2240 2240 ret = -ENOMEM; 2241 2241 pdata = dev_get_platdata(&dev->dev); 2242 - inf = devm_kmalloc(&dev->dev, sizeof(*inf), GFP_KERNEL); 2243 - if (!inf) 2244 - goto failed; 2245 - 2246 2242 if (pdata) { 2247 - *inf = *pdata; 2248 - inf->modes = 2249 - devm_kmalloc_array(&dev->dev, pdata->num_modes, 2250 - sizeof(inf->modes[0]), GFP_KERNEL); 2243 + inf = devm_kmemdup(&dev->dev, pdata, sizeof(*pdata), GFP_KERNEL); 2244 + if (!inf) 2245 + goto failed; 2246 + 2247 + inf->modes = devm_kmemdup_array(&dev->dev, pdata->modes, pdata->num_modes, 2248 + sizeof(*pdata->modes), GFP_KERNEL); 2251 2249 if (!inf->modes) 2252 2250 goto failed; 2253 - for (i = 0; i < inf->num_modes; i++) 2254 - inf->modes[i] = pdata->modes[i]; 2255 2251 } else { 2256 2252 inf = of_pxafb_of_mach_info(&dev->dev); 2253 + if (IS_ERR_OR_NULL(inf)) 2254 + goto failed; 2257 2255 } 2258 - 2259 - if (IS_ERR_OR_NULL(inf)) 2260 - goto failed; 2261 2256 2262 2257 ret = pxafb_parse_options(&dev->dev, g_options, inf); 2263 2258 if (ret < 0)