# \[PATCH 3/4\] video: fbdev: pxafb: handle errors from pxafb\_init\_fbinfo() correctly

- Subsystems: FRAMEBUFFER LAYER, THE REST
- Maintainers: Helge Deller, Linus Torvalds
- List: linux-fbdev
- 3 messages, 3 authors
- Page: https://ratatoskr.run/linux-fbdev/2018/06/13466855/t

## \[PATCH 3/4\] video: fbdev: pxafb: handle errors from pxafb\_init\_fbinfo() correctly

- From: Daniel Mack \<daniel@zonque.org\>
- Date: 2018-06-24 15:38:16 
- Message: https://ratatoskr.run/linux-fbdev/2018/06/13466855.md

```text
pxafb_init_fbinfo() can not only report errors caused by failed
allocations but also when the clock can't be found.

To fix this, return an error pointer instead of NULL in case of errors,
and up-chain the result.

Signed-off-by: Daniel Mack <daniel@zonque.org>
---
 drivers/video/fbdev/pxafb.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/video/fbdev/pxafb.c b/drivers/video/fbdev/pxafb.c
index 6f3a93b3097c..68459b07d442 100644
--- a/drivers/video/fbdev/pxafb.c
+++ b/drivers/video/fbdev/pxafb.c
@@ -1802,14 +1802,14 @@ static struct pxafb_info *pxafb_init_fbinfo(struct device *dev,
 	fbi = devm_kzalloc(dev, sizeof(struct pxafb_info) + sizeof(u32) * 16,
 			   GFP_KERNEL);
 	if (!fbi)
-		return NULL;
+		return ERR_PTR(-ENOMEM);
 
 	fbi->dev = dev;
 	fbi->inf = inf;
 
 	fbi->clk = devm_clk_get(dev, NULL);
 	if (IS_ERR(fbi->clk))
-		return NULL;
+		return ERR_CAST(fbi->clk);
 
 	strcpy(fbi->fb.fix.id, PXA_NAME);
 
@@ -2287,10 +2287,9 @@ static int pxafb_probe(struct platform_device *dev)
 	}
 
 	fbi = pxafb_init_fbinfo(&dev->dev, inf);
-	if (!fbi) {
-		/* only reason for pxafb_init_fbinfo to fail is kmalloc */
+	if (IS_ERR(fbi)) {
 		dev_err(&dev->dev, "Failed to initialize framebuffer device\n");
-		ret = -ENOMEM;
+		ret = PTR_ERR(fbi);
 		goto failed;
 	}
 
-- 
2.17.1

```

## Re: \[PATCH 3/4\] video: fbdev: pxafb: handle errors from pxafb\_init\_fbinfo() correctly

- From: Robert Jarzmik \<robert.jarzmik@free.fr\>
- Date: 2018-06-25 22:02:56 
- Message: https://ratatoskr.run/linux-fbdev/2018/06/13466856.md

```text
Daniel Mack [ref] writes:

> pxafb_init_fbinfo() can not only report errors caused by failed
> allocations but also when the clock can't be found.
>
> To fix this, return an error pointer instead of NULL in case of errors,
> and up-chain the result.
>
> Signed-off-by: Daniel Mack <daniel@zonque.org>
Reviewed-by: Robert Jarzmik <robert.jarzmik@free.fr>

Cheers.

--
Robert
```

## Re: \[PATCH 3/4\] video: fbdev: pxafb: handle errors from pxafb\_init\_fbinfo() correctly

- From: Bartlomiej Zolnierkiewicz \<hidden\>
- Date: 2018-07-24 15:02:18 
- Message: https://ratatoskr.run/linux-fbdev/2018/07/9142592.md

```text
On Sunday, June 24, 2018 05:38:16 PM Daniel Mack wrote:
> pxafb_init_fbinfo() can not only report errors caused by failed
> allocations but also when the clock can't be found.
> 
> To fix this, return an error pointer instead of NULL in case of errors,
> and up-chain the result.
> 
> Signed-off-by: Daniel Mack <daniel@zonque.org>

Patch queued for 4.19, thanks.

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics

```
