Skip to content

Commit

Permalink
media: ttusb-dec: avoid release of non-acquired mutex
Browse files Browse the repository at this point in the history
[ Upstream commit 36b9d69 ]

ttusb_dec_send_command() invokes mutex_lock_interruptible() that can
fail but then it releases the non-acquired mutex. The patch fixes that.

Found by Linux Driver Verification project (linuxtesting.org).

Fixes: dba328b ("media: ttusb-dec: cleanup an error handling logic")
Signed-off-by: Evgeny Novikov <novikov@ispras.ru>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
eunovm authored and gregkh committed Nov 18, 2021
1 parent f8b2ae8 commit 98cb3a0
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions drivers/media/usb/ttusb-dec/ttusb_dec.c
Expand Up @@ -327,7 +327,7 @@ static int ttusb_dec_send_command(struct ttusb_dec *dec, const u8 command,
result = mutex_lock_interruptible(&dec->usb_mutex);
if (result) {
printk("%s: Failed to lock usb mutex.\n", __func__);
goto err;
goto err_free;
}

b[0] = 0xaa;
Expand All @@ -349,7 +349,7 @@ static int ttusb_dec_send_command(struct ttusb_dec *dec, const u8 command,
if (result) {
printk("%s: command bulk message failed: error %d\n",
__func__, result);
goto err;
goto err_mutex_unlock;
}

result = usb_bulk_msg(dec->udev, dec->result_pipe, b,
Expand All @@ -358,7 +358,7 @@ static int ttusb_dec_send_command(struct ttusb_dec *dec, const u8 command,
if (result) {
printk("%s: result bulk message failed: error %d\n",
__func__, result);
goto err;
goto err_mutex_unlock;
} else {
if (debug) {
printk(KERN_DEBUG "%s: result: %*ph\n",
Expand All @@ -371,9 +371,9 @@ static int ttusb_dec_send_command(struct ttusb_dec *dec, const u8 command,
memcpy(cmd_result, &b[4], b[3]);
}

err:
err_mutex_unlock:
mutex_unlock(&dec->usb_mutex);

err_free:
kfree(b);
return result;
}
Expand Down

0 comments on commit 98cb3a0

Please sign in to comment.