Skip to content

Commit 04320b3

Browse files
Colin Ian Kingmchehab
authored andcommitted
media: allegro: fix potential null dereference on header
The pointer header is an alias to msg and msg is being null checked. However, if msg is null then header is also null and this can lead to a null pointer dereference on the assignment type = header->type. Fix this just using header->type after the null check and removing the need for type as it is only used once. Addresses-Coverity: ("Dereference before null check") Fixes: 3de1683 ("media: allegro: add explicit mail encoding and decoding") Signed-off-by: Colin Ian King <[email protected]> Reviewed-by: Michael Tretter <[email protected]> Signed-off-by: Hans Verkuil <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
1 parent dd4eddc commit 04320b3

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

drivers/staging/media/allegro-dvt/allegro-mail.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,13 +462,12 @@ allegro_dec_encode_frame(struct mcu_msg_encode_frame_response *msg, u32 *src)
462462
ssize_t allegro_encode_mail(u32 *dst, void *msg)
463463
{
464464
const struct mcu_msg_header *header = msg;
465-
enum mcu_msg_type type = header->type;
466465
ssize_t size;
467466

468467
if (!msg || !dst)
469468
return -EINVAL;
470469

471-
switch (type) {
470+
switch (header->type) {
472471
case MCU_MSG_TYPE_INIT:
473472
size = allegro_enc_init(&dst[1], msg);
474473
break;

0 commit comments

Comments
 (0)