52aa87ed0411eeeed0454746edae142429cf74c6
[openwrt/openwrt.git] /
1 From 7b4ea31990c1c43ad8ea86d42c1e451c85933d87 Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 Date: Wed, 15 Jan 2020 14:02:43 +0000
4 Subject: [PATCH] driver: char: rpivid: Add error handling to the
5 legacy device load
6
7 The return value from device_create for the legacy device was never
8 checked or handled. Add the required error handling.
9
10 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
11 ---
12 drivers/char/broadcom/rpivid-mem.c | 11 +++++++++--
13 1 file changed, 9 insertions(+), 2 deletions(-)
14
15 --- a/drivers/char/broadcom/rpivid-mem.c
16 +++ b/drivers/char/broadcom/rpivid-mem.c
17 @@ -201,9 +201,14 @@ static int rpivid_mem_probe(struct platf
18 oldname[3] = 'g';
19 oldname[4] = 'o';
20 oldname[5] = 'n';
21 - (void)device_create(priv->class, NULL, priv->devid + 1, NULL,
22 - oldname + 1);
23 + dev = device_create(priv->class, NULL, priv->devid + 1, NULL,
24 + oldname + 1);
25 kfree(oldname);
26 +
27 + if (IS_ERR(dev)) {
28 + err = PTR_ERR(dev);
29 + goto failed_legacy_device_create;
30 + }
31 }
32
33 dev_info(priv->dev, "%s initialised: Registers at 0x%08lx length 0x%08lx",
34 @@ -211,6 +216,8 @@ static int rpivid_mem_probe(struct platf
35
36 return 0;
37
38 +failed_legacy_device_create:
39 + device_destroy(priv->class, priv->devid);
40 failed_device_create:
41 class_destroy(priv->class);
42 failed_class_create: