diff options
author | Colin Ian King <colin.king@canonical.com> | 2018-11-24 12:34:10 +0000 |
---|---|---|
committer | Ben Hutchings <ben@decadent.org.uk> | 2019-04-04 16:13:45 +0100 |
commit | 47cf54a6b6edae510890398b209bd8476fc4ef82 (patch) | |
tree | 5ed8dd41a33d66f6b5188b0454689d6af7fffd74 | |
parent | 6acfa0b5a8cd7bc4ff805be7f5a9914a0eff7f3c (diff) | |
download | linux-stable-47cf54a6b6edae510890398b209bd8476fc4ef82.tar.gz linux-stable-47cf54a6b6edae510890398b209bd8476fc4ef82.tar.bz2 linux-stable-47cf54a6b6edae510890398b209bd8476fc4ef82.zip |
altera-stapl: check for a null key before strcasecmp'ing it
commit 9ccb645683ef46e3c52c12c088a368baa58447d4 upstream.
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>
[bwh: Backported to 3.16: old code used strnicmp()]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
-rw-r--r-- | drivers/misc/altera-stapl/altera.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/drivers/misc/altera-stapl/altera.c b/drivers/misc/altera-stapl/altera.c index 24272e022bec..69e08013deb9 100644 --- a/drivers/misc/altera-stapl/altera.c +++ b/drivers/misc/altera-stapl/altera.c @@ -2176,8 +2176,7 @@ static int altera_get_note(u8 *p, s32 program_size, key_ptr = &p[note_strings + get_unaligned_be32( &p[note_table + (8 * i)])]; - if ((strnicmp(key, key_ptr, strlen(key_ptr)) == 0) && - (key != NULL)) { + if (key && !strncasecmp(key, key_ptr, strlen(key_ptr))) { status = 0; value_ptr = &p[note_strings + |