staging: vchiq_core: Bailout if VCHIQ state is already initialized
authorStefan Wahren <stefan.wahren@i2se.com>
Thu, 25 May 2017 22:26:20 +0000 (00:26 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 29 May 2017 15:04:12 +0000 (17:04 +0200)
In case VCHIQ state is already initialized we need to bailout
in order to aovid a memory leak.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c

index c47de9692c8c72db6bcbdb7e49b4b3d98b8854fe..0a46e1525d8cc35d837f15e529312c020043d64e 100644 (file)
@@ -2355,6 +2355,11 @@ vchiq_init_state(VCHIQ_STATE_T *state, VCHIQ_SLOT_ZERO_T *slot_zero,
                "%s: slot_zero = %pK, is_master = %d",
                __func__, slot_zero, is_master);
 
+       if (vchiq_states[0]) {
+               pr_err("%s: VCHIQ state already initialized\n", __func__);
+               return VCHIQ_ERROR;
+       }
+
        /* Check the input configuration */
 
        if (slot_zero->magic != VCHIQ_MAGIC) {