# \[PATCH\] fbdev: n411: check return value

- Subsystems: FRAMEBUFFER LAYER, THE REST
- Maintainers: Helge Deller, Linus Torvalds
- List: linux-fbdev
- 2 messages, 2 authors
- Page: https://ratatoskr.run/linux-fbdev/2016/02/4691759/t

## \[PATCH\] fbdev: n411: check return value

- From: Sudip Mukherjee \<sudipm.mukherjee@gmail.com\>
- Date: 2016-02-23 12:44:29 
- Message: https://ratatoskr.run/linux-fbdev/2016/02/4691759.md

```text
We were not checking the return value of platform_device_add_data()
which can fail.

Signed-off-by: Sudip Mukherjee <sudip.mukherjee@codethink.co.uk>
---
 drivers/video/fbdev/n411.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/video/fbdev/n411.c b/drivers/video/fbdev/n411.c
index 935830f..053deac 100644
--- a/drivers/video/fbdev/n411.c
+++ b/drivers/video/fbdev/n411.c
@@ -165,16 +165,22 @@ static int __init n411_init(void)
 	if (!n411_device)
 		return -ENOMEM;
 
-	platform_device_add_data(n411_device, &n411_board, sizeof(n411_board));
+	ret = platform_device_add_data(n411_device, &n411_board,
+				       sizeof(n411_board));
+	if (ret)
+		goto put_plat_device;
 
 	/* this _add binds hecubafb to n411. hecubafb refcounts n411 */
 	ret = platform_device_add(n411_device);
 
 	if (ret)
-		platform_device_put(n411_device);
+		goto put_plat_device;
 
-	return ret;
+	return 0;
 
+put_plat_device:
+	platform_device_put(n411_device);
+	return ret;
 }
 
 static void __exit n411_exit(void)
-- 
1.9.1

```

## Re: \[PATCH\] fbdev: n411: check return value

- From: Tomi Valkeinen \<hidden\>
- Date: 2016-02-26 10:18:09 
- Message: https://ratatoskr.run/linux-fbdev/2016/02/4695145.md

```text


On 23/02/16 14:44, Sudip Mukherjee wrote:
> We were not checking the return value of platform_device_add_data()
> which can fail.
> 
> Signed-off-by: Sudip Mukherjee <sudip.mukherjee@codethink.co.uk>
> ---
>  drivers/video/fbdev/n411.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)

Thanks, queued for 4.6.

 Tomi

```
