diff mbox series

Bluetooth: Fix unused value warning in sco_sock_connect

Message ID 20240323072253.40816-1-bharathsm@microsoft.com
State New
Headers show
Series Bluetooth: Fix unused value warning in sco_sock_connect | expand

Commit Message

Bharath SM March 23, 2024, 7:22 a.m. UTC
Coverity complains of an unused value:

CID 1528147: (#1 of 1): Unused value (UNUSED_VALUE)
assigned_value: Assigning value -22 to err here, but that stored
value is overwritten before it can be used.
	err = -EINVAL;

Fix it by removing the assignment.

Signed-off-by: Bharath SM <bharathsm@microsoft.com>
---
 net/bluetooth/sco.c | 3 ---
 1 file changed, 3 deletions(-)

Comments

Pauli Virtanen March 23, 2024, 9:51 a.m. UTC | #1
Hi,

la, 2024-03-23 kello 12:52 +0530, Bharath SM kirjoitti:
> Coverity complains of an unused value:
> 
> CID 1528147: (#1 of 1): Unused value (UNUSED_VALUE)
> assigned_value: Assigning value -22 to err here, but that stored
> value is overwritten before it can be used.
> 	err = -EINVAL;
> 
> Fix it by removing the assignment.
> 
> Signed-off-by: Bharath SM <bharathsm@microsoft.com>
> ---
>  net/bluetooth/sco.c | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c
> index 43daf965a01e..e74bce4e1d6c 100644
> --- a/net/bluetooth/sco.c
> +++ b/net/bluetooth/sco.c
> @@ -581,9 +581,6 @@ static int sco_sock_connect(struct socket *sock, struct sockaddr *addr, int alen
>  	if (sk->sk_state != BT_OPEN && sk->sk_state != BT_BOUND)
>  		return -EBADFD;
>  
> -	if (sk->sk_type != SOCK_SEQPACKET)
> -		err = -EINVAL;
> -

It should return -EINVAL here, not remove the check.

Looks like it got broken in 9a8ec9e8ebb5a7c0cfbce2d6b4a6b67b2b78e8f3 in
the locking refactoring.

>  	lock_sock(sk);
>  	/* Set destination address and psm */
>  	bacpy(&sco_pi(sk)->dst, &sa->sco_bdaddr);
diff mbox series

Patch

diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c
index 43daf965a01e..e74bce4e1d6c 100644
--- a/net/bluetooth/sco.c
+++ b/net/bluetooth/sco.c
@@ -581,9 +581,6 @@  static int sco_sock_connect(struct socket *sock, struct sockaddr *addr, int alen
 	if (sk->sk_state != BT_OPEN && sk->sk_state != BT_BOUND)
 		return -EBADFD;
 
-	if (sk->sk_type != SOCK_SEQPACKET)
-		err = -EINVAL;
-
 	lock_sock(sk);
 	/* Set destination address and psm */
 	bacpy(&sco_pi(sk)->dst, &sa->sco_bdaddr);