087e3e50253b79621a092b3790e0dd1f353518e0
[oweals/openwrt.git] /
1 From 73979b06255c3b7b536a53d09ea095aec8ed37aa Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.org>
3 Date: Mon, 3 Dec 2018 12:50:38 +0000
4 Subject: [PATCH] staging: vchiq_arm: Improve error handling on loading
5  drivers
6
7 The handling of loading platform drivers requires checking IS_ERR
8 for the pointer on unload.
9 If the driver fails to load, NULL the pointer during probe as
10 platform_device_unregister already checks for NULL.
11
12 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
13 ---
14  .../vc04_services/interface/vchiq_arm/vchiq_arm.c    | 12 ++++++++----
15  1 file changed, 8 insertions(+), 4 deletions(-)
16
17 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
18 +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
19 @@ -3654,6 +3654,8 @@ static int vchiq_probe(struct platform_d
20                 MAJOR(vchiq_devid), MINOR(vchiq_devid));
21  
22         bcm2835_camera = vchiq_register_child(pdev, "bcm2835-camera");
23 +       if (IS_ERR(bcm2835_camera))
24 +               bcm2835_camera = NULL;
25  
26         return 0;
27  
28 @@ -3670,8 +3672,9 @@ failed_platform_init:
29  
30  static int vchiq_remove(struct platform_device *pdev)
31  {
32 -       if (!IS_ERR(bcm2835_camera))
33 -               platform_device_unregister(bcm2835_camera);
34 +       platform_device_unregister(bcm2835_codec);
35 +       platform_device_unregister(bcm2835_camera);
36 +       platform_device_unregister(vcsm_cma);
37         vchiq_debugfs_deinit();
38         device_destroy(vchiq_class, vchiq_devid);
39         class_destroy(vchiq_class);