Skip to contentSkip to conversation

optee: Fix NULL but dereferenced coccicheck error

PATCH Applied Yang Li 2 participants 2 messages Nov 22, 2021 – Nov 29, 2021

Subsystems (2)
lore
Share & tools
lore

Yang Li

author
#0 lore raw

PATCH v2 1/1 optee: Fix NULL but dereferenced coccicheck error

Eliminate the following coccicheck warning:
./drivers/tee/optee/smc_abi.c:1508:12-15: ERROR: optee is NULL but dereferenced.

Fixes 'commit 6749e69c4dad ("optee: add asynchronous notifications")'

---

change in v2:
--According to Jens's suggestion
fixed as:

        if (memremaped_shm)
                memunmap(memremaped_shm);
 drivers/tee/optee/smc_abi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/tee/optee/smc_abi.c +2 -2
index 92759d7..d7c8235 100644
@@ -1505,8 +1505,8 @@ static int optee_probe(struct platform_device *pdev)
 	kfree(optee);
 err_free_pool:
 	tee_shm_pool_free(pool);
-	if (optee->smc.memremaped_shm)
-		memunmap(optee->smc.memremaped_shm);
+	if (memremaped_shm)
+		memunmap(memremaped_shm);
 	return rc;
 }
 
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 10 lines · Yang Li

Eliminate the following coccicheck warning:
./drivers/tee/optee/smc_abi.c:1508:12-15: ERROR: optee is NULL but dereferenced.

Fixes 'commit 6749e69c4dad ("optee: add asynchronous notifications")'

---

Quoted 8 lines

change in v2:
--According to Jens's suggestion
fixed as:

        if (memremaped_shm)
                memunmap(memremaped_shm);
 drivers/tee/optee/smc_abi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Applied to https://git.linaro.org/people/jens.wiklander/linux-tee.git/
async_notif

Thanks,
Jens

Quoted 19 lines
drivers/tee/optee/smc_abi.c +2 -3
index 92759d7..d7c8235 100644
@@ -1505,8 +1505,8 @@ static int optee_probe(struct platform_device *pdev)
        kfree(optee);
 err_free_pool:
        tee_shm_pool_free(pool);
-       if (optee->smc.memremaped_shm)
-               memunmap(optee->smc.memremaped_shm);
+       if (memremaped_shm)
+               memunmap(memremaped_shm);
        return rc;
 }
 
--

1.8.3.1