Skip to content

Commit b347f45

Browse files
raagjadavhdeller
authored andcommitted
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>
1 parent 892c788 commit b347f45

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

drivers/video/fbdev/pxafb.c

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2233,32 +2233,27 @@ static int pxafb_probe(struct platform_device *dev)
22332233
{
22342234
struct pxafb_info *fbi;
22352235
struct pxafb_mach_info *inf, *pdata;
2236-
int i, irq, ret;
2236+
int irq, ret;
22372237

22382238
dev_dbg(&dev->dev, "pxafb_probe\n");
22392239

22402240
ret = -ENOMEM;
22412241
pdata = dev_get_platdata(&dev->dev);
2242-
inf = devm_kmalloc(&dev->dev, sizeof(*inf), GFP_KERNEL);
2243-
if (!inf)
2244-
goto failed;
2245-
22462242
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);
22512249
if (!inf->modes)
22522250
goto failed;
2253-
for (i = 0; i < inf->num_modes; i++)
2254-
inf->modes[i] = pdata->modes[i];
22552251
} else {
22562252
inf = of_pxafb_of_mach_info(&dev->dev);
2253+
if (IS_ERR_OR_NULL(inf))
2254+
goto failed;
22572255
}
22582256

2259-
if (IS_ERR_OR_NULL(inf))
2260-
goto failed;
2261-
22622257
ret = pxafb_parse_options(&dev->dev, g_options, inf);
22632258
if (ret < 0)
22642259
goto failed;

0 commit comments

Comments
 (0)