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
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.
12 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
14 .../vc04_services/interface/vchiq_arm/vchiq_arm.c | 12 ++++++++----
15 1 file changed, 8 insertions(+), 4 deletions(-)
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 @@ -3655,7 +3655,11 @@ static int vchiq_probe(struct platform_d
20 MAJOR(vchiq_devid), MINOR(vchiq_devid));
22 bcm2835_camera = vchiq_register_child(pdev, "bcm2835-camera");
23 + if (IS_ERR(bcm2835_camera))
24 + bcm2835_camera = NULL;
25 bcm2835_audio = vchiq_register_child(pdev, "bcm2835_audio");
26 + if (IS_ERR(bcm2835_audio))
27 + bcm2835_audio = NULL;
31 @@ -3672,10 +3676,10 @@ failed_platform_init:
33 static int vchiq_remove(struct platform_device *pdev)
35 - if (!IS_ERR(bcm2835_audio))
36 - platform_device_unregister(bcm2835_audio);
37 - if (!IS_ERR(bcm2835_camera))
38 - platform_device_unregister(bcm2835_camera);
39 + platform_device_unregister(bcm2835_codec);
40 + platform_device_unregister(bcm2835_audio);
41 + platform_device_unregister(bcm2835_camera);
42 + platform_device_unregister(vcsm_cma);
43 vchiq_debugfs_deinit();
44 device_destroy(vchiq_class, vchiq_devid);
45 class_destroy(vchiq_class);