altera-stapl: check for a null key before strcasecmp'ing it
authorColin Ian King <colin.king@canonical.com>
Sat, 24 Nov 2018 12:34:10 +0000 (12:34 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 13 Dec 2019 07:51:56 +0000 (08:51 +0100)
commitf6ea3c03ec082abfe2b6519e93f10fe9ec37c5a2
treeb2694a59d561a9739e1927bdc3a09ef099b381ab
parentd7e82b903dbd5f0295dad4a807ae1faf4ed5461e
altera-stapl: check for a null key before strcasecmp'ing it

[ Upstream commit 9ccb645683ef46e3c52c12c088a368baa58447d4 ]

Currently the null check on key is occurring after the strcasecmp on
the key, hence there is a potential null pointer dereference on key.
Fix this by checking if key is null first. Also replace the == 0
check on strcasecmp with just the ! operator.

Detected by CoverityScan, CID#1248787 ("Dereference before null check")

Fixes: fa766c9be58b ("[media] Altera FPGA firmware download module")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/misc/altera-stapl/altera.c