Skip to content

Commit

Permalink
Bluetooth: Fix passing NULL to PTR_ERR
Browse files Browse the repository at this point in the history
commit 266191a upstream.

Passing NULL to PTR_ERR will result in 0 (success), also since the likes of
bt_skb_sendmsg does never return NULL it is safe to replace the instances of
IS_ERR_OR_NULL with IS_ERR when checking its return.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Tested-by: Tedd Ho-Jeong An <tedd.an@intel.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Cc: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Luiz Augusto von Dentz authored and Greg Kroah-Hartman committed Jul 29, 2022
1 parent 10bacb8 commit aa2d34c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion include/net/bluetooth/bluetooth.h
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ static inline struct sk_buff *bt_skb_sendmmsg(struct sock *sk,
struct sk_buff *tmp;

tmp = bt_skb_sendmsg(sk, msg, len, mtu, headroom, tailroom);
if (IS_ERR_OR_NULL(tmp)) {
if (IS_ERR(tmp)) {
kfree_skb(skb);
return tmp;
}
Expand Down
2 changes: 1 addition & 1 deletion net/bluetooth/rfcomm/sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ static int rfcomm_sock_sendmsg(struct socket *sock, struct msghdr *msg,

skb = bt_skb_sendmmsg(sk, msg, len, d->mtu, RFCOMM_SKB_HEAD_RESERVE,
RFCOMM_SKB_TAIL_RESERVE);
if (IS_ERR_OR_NULL(skb))
if (IS_ERR(skb))
return PTR_ERR(skb);

sent = rfcomm_dlc_send(d, skb);
Expand Down
2 changes: 1 addition & 1 deletion net/bluetooth/sco.c
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ static int sco_sock_sendmsg(struct socket *sock, struct msghdr *msg,
return -EOPNOTSUPP;

skb = bt_skb_sendmsg(sk, msg, len, len, 0, 0);
if (IS_ERR_OR_NULL(skb))
if (IS_ERR(skb))
return PTR_ERR(skb);

lock_sock(sk);
Expand Down

0 comments on commit aa2d34c

Please sign in to comment.