tree:
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head: bdecf38f228bcca73b31ada98b5b7ba1215eb9c9
commit: 3ee7b7cd83900bb711efadbf16fa096a615a1566 [812/9662] Bluetooth: Add BT_MODE socket
option
reproduce:
# apt-get install sparse
# sparse version: v0.6.1-193-gb8fad4bc-dirty
git checkout 3ee7b7cd83900bb711efadbf16fa096a615a1566
make ARCH=x86_64 allmodconfig
make C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'
If you fix the issue, kindly add following tag as appropriate
Reported-by: kbuild test robot <lkp(a)intel.com>
sparse warnings: (new ones prefixed by >>)
./arch/xtensa/include/generated/uapi/asm/unistd_32.h:393:41: sparse: sparse: no newline
at end of file
net/bluetooth/l2cap_sock.c:428:13: sparse: sparse: incorrect type in initializer
(different address spaces) @@ expected int const *__gu_addr @@ got int [noderefint
const *__gu_addr @@
net/bluetooth/l2cap_sock.c:428:13: sparse: expected int const *__gu_addr
net/bluetooth/l2cap_sock.c:428:13: sparse: got int [noderef] <asn:1> *optlen
net/bluetooth/l2cap_sock.c:428:13: sparse: sparse: incorrect type in argument 2
(different address spaces) @@ expected void const [noderef] <asn:1> *from @@
got ] <asn:1> *from @@
net/bluetooth/l2cap_sock.c:428:13: sparse: expected void const [noderef]
<asn:1> *from
net/bluetooth/l2cap_sock.c:428:13: sparse: got int const *__gu_addr
net/bluetooth/l2cap_sock.c:503:21: sparse: sparse: incorrect type in initializer
(different address spaces) @@ expected unsigned int *__pu_addr @@ got unsigned int
[noderef] [usertunsigned int *__pu_addr @@
net/bluetooth/l2cap_sock.c:503:21: sparse: expected unsigned int *__pu_addr
net/bluetooth/l2cap_sock.c:503:21: sparse: got unsigned int [noderef] [usertype]
<asn:1> *
net/bluetooth/l2cap_sock.c:503:21: sparse: sparse: incorrect type in argument 1
(different address spaces) @@ expected void [noderef] <asn:1> *to @@ got ref]
<asn:1> *to @@
net/bluetooth/l2cap_sock.c:503:21: sparse: expected void [noderef] <asn:1>
*to
net/bluetooth/l2cap_sock.c:503:21: sparse: got unsigned int *__pu_addr
net/bluetooth/l2cap_sock.c:553:13: sparse: sparse: incorrect type in initializer
(different address spaces) @@ expected int const *__gu_addr @@ got int [noderefint
const *__gu_addr @@
net/bluetooth/l2cap_sock.c:553:13: sparse: expected int const *__gu_addr
net/bluetooth/l2cap_sock.c:553:13: sparse: got int [noderef] <asn:1> *optlen
net/bluetooth/l2cap_sock.c:553:13: sparse: sparse: incorrect type in argument 2
(different address spaces) @@ expected void const [noderef] <asn:1> *from @@
got ] <asn:1> *from @@
net/bluetooth/l2cap_sock.c:553:13: sparse: expected void const [noderef]
<asn:1> *from
net/bluetooth/l2cap_sock.c:553:13: sparse: got int const *__gu_addr
net/bluetooth/l2cap_sock.c:589:21: sparse: sparse: incorrect type in initializer
(different address spaces) @@ expected unsigned int *__pu_addr @@ got unsigned int
[noderef] [usertunsigned int *__pu_addr @@
net/bluetooth/l2cap_sock.c:589:21: sparse: expected unsigned int *__pu_addr
net/bluetooth/l2cap_sock.c:589:21: sparse: got unsigned int [noderef] [usertype]
<asn:1> *
net/bluetooth/l2cap_sock.c:589:21: sparse: sparse: incorrect type in argument 1
(different address spaces) @@ expected void [noderef] <asn:1> *to @@ got ref]
<asn:1> *to @@
net/bluetooth/l2cap_sock.c:589:21: sparse: expected void [noderef] <asn:1>
*to
net/bluetooth/l2cap_sock.c:589:21: sparse: got unsigned int *__pu_addr
net/bluetooth/l2cap_sock.c:596:21: sparse: sparse: incorrect type in initializer
(different address spaces) @@ expected unsigned int *__pu_addr @@ got unsigned int
[noderef] [usertunsigned int *__pu_addr @@
net/bluetooth/l2cap_sock.c:596:21: sparse: expected unsigned int *__pu_addr
net/bluetooth/l2cap_sock.c:596:21: sparse: got unsigned int [noderef] [usertype]
<asn:1> *
net/bluetooth/l2cap_sock.c:596:21: sparse: sparse: incorrect type in argument 1
(different address spaces) @@ expected void [noderef] <asn:1> *to @@ got ref]
<asn:1> *to @@
net/bluetooth/l2cap_sock.c:596:21: sparse: expected void [noderef] <asn:1>
*to
net/bluetooth/l2cap_sock.c:596:21: sparse: got unsigned int *__pu_addr
net/bluetooth/l2cap_sock.c:618:21: sparse: sparse: incorrect type in initializer
(different address spaces) @@ expected unsigned int *__pu_addr @@ got unsigned int
[noderef] [usertunsigned int *__pu_addr @@
net/bluetooth/l2cap_sock.c:618:21: sparse: expected unsigned int *__pu_addr
net/bluetooth/l2cap_sock.c:618:21: sparse: got unsigned int [noderef] [usertype]
<asn:1> *
net/bluetooth/l2cap_sock.c:618:21: sparse: sparse: incorrect type in argument 1
(different address spaces) @@ expected void [noderef] <asn:1> *to @@ got ref]
<asn:1> *to @@
net/bluetooth/l2cap_sock.c:618:21: sparse: expected void [noderef] <asn:1>
*to
net/bluetooth/l2cap_sock.c:618:21: sparse: got unsigned int *__pu_addr
net/bluetooth/l2cap_sock.c:633:21: sparse: sparse: incorrect type in initializer
(different address spaces) @@ expected unsigned short *__pu_addr @@ got unsigned
short [noderef] [useunsigned short *__pu_addr @@
net/bluetooth/l2cap_sock.c:633:21: sparse: expected unsigned short *__pu_addr
net/bluetooth/l2cap_sock.c:633:21: sparse: got unsigned short [noderef] [usertype]
<asn:1> *
net/bluetooth/l2cap_sock.c:633:21: sparse: sparse: incorrect type in argument 1
(different address spaces) @@ expected void [noderef] <asn:1> *to @@ got
deref] <asn:1> *to @@
net/bluetooth/l2cap_sock.c:633:21: sparse: expected void [noderef] <asn:1>
*to
net/bluetooth/l2cap_sock.c:633:21: sparse: got unsigned short *__pu_addr
net/bluetooth/l2cap_sock.c:643:21: sparse: sparse: incorrect type in initializer
(different address spaces) @@ expected unsigned short *__pu_addr @@ got unsigned
short [noderef] [useunsigned short *__pu_addr @@
net/bluetooth/l2cap_sock.c:643:21: sparse: expected unsigned short *__pu_addr
net/bluetooth/l2cap_sock.c:643:21: sparse: got unsigned short [noderef] [usertype]
<asn:1> *
net/bluetooth/l2cap_sock.c:643:21: sparse: sparse: incorrect type in argument 1
(different address spaces) @@ expected void [noderef] <asn:1> *to @@ got
deref] <asn:1> *to @@
net/bluetooth/l2cap_sock.c:643:21: sparse: expected void [noderef] <asn:1>
*to
net/bluetooth/l2cap_sock.c:643:21: sparse: got unsigned short *__pu_addr
net/bluetooth/l2cap_sock.c:655:21: sparse: sparse: incorrect type in initializer
(different address spaces) @@ expected unsigned int *__pu_addr @@ got unsigned int
[noderef] [usertunsigned int *__pu_addr @@
net/bluetooth/l2cap_sock.c:655:21: sparse: expected unsigned int *__pu_addr
net/bluetooth/l2cap_sock.c:655:21: sparse: got unsigned int [noderef] [usertype]
<asn:1> *
net/bluetooth/l2cap_sock.c:655:21: sparse: sparse: incorrect type in argument 1
(different address spaces) @@ expected void [noderef] <asn:1> *to @@ got ref]
<asn:1> *to @@
net/bluetooth/l2cap_sock.c:655:21: sparse: expected void [noderef] <asn:1>
*to
net/bluetooth/l2cap_sock.c:655:21: sparse: got unsigned int *__pu_addr
> net/bluetooth/l2cap_sock.c:676:21: sparse: sparse: incorrect type
in initializer (different address spaces) @@ expected unsigned char *__pu_addr @@
got unsigned char [noderef] [userunsigned char *__pu_addr @@
> net/bluetooth/l2cap_sock.c:676:21: sparse: expected unsigned char *__pu_addr
net/bluetooth/l2cap_sock.c:676:21: sparse: got unsigned char [noderef]
[usertype] <asn:1> *
> net/bluetooth/l2cap_sock.c:676:21: sparse: sparse: incorrect type
in argument 1 (different address spaces) @@ expected void [noderef] <asn:1> *to
@@ got eref] <asn:1> *to @@
net/bluetooth/l2cap_sock.c:676:21: sparse:
expected void [noderef] <asn:1> *to
> net/bluetooth/l2cap_sock.c:676:21: sparse: got unsigned char
*__pu_addr
net/bluetooth/l2cap_sock.c:785:21: sparse: sparse: incorrect type in
initializer (different address spaces) @@ expected unsigned int const *__gu_addr @@
got unsigned int [noderef] unsigned int const *__gu_addr @@
net/bluetooth/l2cap_sock.c:785:21: sparse: expected unsigned int const *__gu_addr
net/bluetooth/l2cap_sock.c:785:21: sparse: got unsigned int [noderef] [usertype]
<asn:1> *
net/bluetooth/l2cap_sock.c:785:21: sparse: sparse: incorrect type in argument 2
(different address spaces) @@ expected void const [noderef] <asn:1> *from @@
got [noderef] <asn:1> *from @@
net/bluetooth/l2cap_sock.c:785:21: sparse: expected void const [noderef]
<asn:1> *from
net/bluetooth/l2cap_sock.c:785:21: sparse: got unsigned int const *__gu_addr
net/bluetooth/l2cap_sock.c:942:21: sparse: sparse: incorrect type in initializer
(different address spaces) @@ expected unsigned int const *__gu_addr @@ got unsigned
int [noderef] unsigned int const *__gu_addr @@
net/bluetooth/l2cap_sock.c:942:21: sparse: expected unsigned int const *__gu_addr
net/bluetooth/l2cap_sock.c:942:21: sparse: got unsigned int [noderef] [usertype]
<asn:1> *
net/bluetooth/l2cap_sock.c:942:21: sparse: sparse: incorrect type in argument 2
(different address spaces) @@ expected void const [noderef] <asn:1> *from @@
got [noderef] <asn:1> *from @@
net/bluetooth/l2cap_sock.c:942:21: sparse: expected void const [noderef]
<asn:1> *from
net/bluetooth/l2cap_sock.c:942:21: sparse: got unsigned int const *__gu_addr
net/bluetooth/l2cap_sock.c:957:21: sparse: sparse: incorrect type in initializer
(different address spaces) @@ expected unsigned int const *__gu_addr @@ got unsigned
int [noderef] unsigned int const *__gu_addr @@
net/bluetooth/l2cap_sock.c:957:21: sparse: expected unsigned int const *__gu_addr
net/bluetooth/l2cap_sock.c:957:21: sparse: got unsigned int [noderef] [usertype]
<asn:1> *
net/bluetooth/l2cap_sock.c:957:21: sparse: sparse: incorrect type in argument 2
(different address spaces) @@ expected void const [noderef] <asn:1> *from @@
got [noderef] <asn:1> *from @@
net/bluetooth/l2cap_sock.c:957:21: sparse: expected void const [noderef]
<asn:1> *from
net/bluetooth/l2cap_sock.c:957:21: sparse: got unsigned int const *__gu_addr
net/bluetooth/l2cap_sock.c:1005:21: sparse: sparse: incorrect type in initializer
(different address spaces) @@ expected unsigned int const *__gu_addr @@ got unsigned
int [noderef] unsigned int const *__gu_addr @@
net/bluetooth/l2cap_sock.c:1005:21: sparse: expected unsigned int const *__gu_addr
net/bluetooth/l2cap_sock.c:1005:21: sparse: got unsigned int [noderef] [usertype]
<asn:1> *
net/bluetooth/l2cap_sock.c:1005:21: sparse: sparse: incorrect type in argument 2
(different address spaces) @@ expected void const [noderef] <asn:1> *from @@
got [noderef] <asn:1> *from @@
net/bluetooth/l2cap_sock.c:1005:21: sparse: expected void const [noderef]
<asn:1> *from
net/bluetooth/l2cap_sock.c:1005:21: sparse: got unsigned int const *__gu_addr
net/bluetooth/l2cap_sock.c:1053:21: sparse: sparse: incorrect type in initializer
(different address spaces) @@ expected unsigned short const *__gu_addr @@ got
unsigned short [noderefunsigned short const *__gu_addr @@
net/bluetooth/l2cap_sock.c:1053:21: sparse: expected unsigned short const
*__gu_addr
net/bluetooth/l2cap_sock.c:1053:21: sparse: got unsigned short [noderef] [usertype]
<asn:1> *
net/bluetooth/l2cap_sock.c:1053:21: sparse: sparse: incorrect type in argument 2
(different address spaces) @@ expected void const [noderef] <asn:1> *from @@
got st [noderef] <asn:1> *from @@
net/bluetooth/l2cap_sock.c:1053:21: sparse: expected void const [noderef]
<asn:1> *from
net/bluetooth/l2cap_sock.c:1053:21: sparse: got unsigned short const *__gu_addr
> net/bluetooth/l2cap_sock.c:1084:21: sparse: sparse: incorrect
type in initializer (different address spaces) @@ expected unsigned char const
*__gu_addr @@ got unsigned char [noderef]unsigned char const *__gu_addr @@
> net/bluetooth/l2cap_sock.c:1084:21: sparse: expected unsigned char const
*__gu_addr
net/bluetooth/l2cap_sock.c:1084:21: sparse: got unsigned char
[noderef] [usertype] <asn:1> *
> net/bluetooth/l2cap_sock.c:1084:21: sparse: sparse: incorrect
type in argument 2 (different address spaces) @@ expected void const [noderef]
<asn:1> *from @@ got t [noderef] <asn:1> *from @@
net/bluetooth/l2cap_sock.c:1084:21: sparse: expected void const [noderef] <asn:1>
*from
> net/bluetooth/l2cap_sock.c:1084:21: sparse: got unsigned char
const *__gu_addr
vim +676 net/bluetooth/l2cap_sock.c
534
535 static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname,
536 char __user *optval, int __user *optlen)
537 {
538 struct sock *sk = sock->sk;
539 struct l2cap_chan *chan = l2cap_pi(sk)->chan;
540 struct bt_security sec;
541 struct bt_power pwr;
542 u32 phys;
543 int len, mode, err = 0;
544
545 BT_DBG("sk %p", sk);
546
547 if (level == SOL_L2CAP)
548 return l2cap_sock_getsockopt_old(sock, optname, optval, optlen);
549
550 if (level != SOL_BLUETOOTH)
551 return -ENOPROTOOPT;
552
553 if (get_user(len, optlen))
554 return -EFAULT;
555
556 lock_sock(sk);
557
558 switch (optname) {
559 case BT_SECURITY:
560 if (chan->chan_type != L2CAP_CHAN_CONN_ORIENTED &&
561 chan->chan_type != L2CAP_CHAN_FIXED &&
562 chan->chan_type != L2CAP_CHAN_RAW) {
563 err = -EINVAL;
564 break;
565 }
566
567 memset(&sec, 0, sizeof(sec));
568 if (chan->conn) {
569 sec.level = chan->conn->hcon->sec_level;
570
571 if (sk->sk_state == BT_CONNECTED)
572 sec.key_size = chan->conn->hcon->enc_key_size;
573 } else {
574 sec.level = chan->sec_level;
575 }
576
577 len = min_t(unsigned int, len, sizeof(sec));
578 if (copy_to_user(optval, (char *) &sec, len))
579 err = -EFAULT;
580
581 break;
582
583 case BT_DEFER_SETUP:
584 if (sk->sk_state != BT_BOUND && sk->sk_state != BT_LISTEN) {
585 err = -EINVAL;
586 break;
587 }
588
589 if (put_user(test_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags),
590 (u32 __user *) optval))
591 err = -EFAULT;
592
593 break;
594
595 case BT_FLUSHABLE:
596 if (put_user(test_bit(FLAG_FLUSHABLE, &chan->flags),
597 (u32 __user *) optval))
598 err = -EFAULT;
599
600 break;
601
602 case BT_POWER:
603 if (sk->sk_type != SOCK_SEQPACKET && sk->sk_type != SOCK_STREAM
604 && sk->sk_type != SOCK_RAW) {
605 err = -EINVAL;
606 break;
607 }
608
609 pwr.force_active = test_bit(FLAG_FORCE_ACTIVE, &chan->flags);
610
611 len = min_t(unsigned int, len, sizeof(pwr));
612 if (copy_to_user(optval, (char *) &pwr, len))
613 err = -EFAULT;
614
615 break;
616
617 case BT_CHANNEL_POLICY:
618 if (put_user(chan->chan_policy, (u32 __user *) optval))
619 err = -EFAULT;
620 break;
621
622 case BT_SNDMTU:
623 if (!bdaddr_type_is_le(chan->src_type)) {
624 err = -EINVAL;
625 break;
626 }
627
628 if (sk->sk_state != BT_CONNECTED) {
629 err = -ENOTCONN;
630 break;
631 }
632
633 if (put_user(chan->omtu, (u16 __user *) optval))
634 err = -EFAULT;
635 break;
636
637 case BT_RCVMTU:
638 if (!bdaddr_type_is_le(chan->src_type)) {
639 err = -EINVAL;
640 break;
641 }
642
643 if (put_user(chan->imtu, (u16 __user *) optval))
644 err = -EFAULT;
645 break;
646
647 case BT_PHY:
648 if (sk->sk_state != BT_CONNECTED) {
649 err = -ENOTCONN;
650 break;
651 }
652
653 phys = hci_conn_get_phy(chan->conn->hcon);
654
655 if (put_user(phys, (u32 __user *) optval))
656 err = -EFAULT;
657 break;
658
659 case BT_MODE:
660 if (!enable_ecred) {
661 err = -ENOPROTOOPT;
662 break;
663 }
664
665 if (chan->chan_type != L2CAP_CHAN_CONN_ORIENTED) {
666 err = -EINVAL;
667 break;
668 }
669
670 mode = l2cap_get_mode(chan);
671 if (mode < 0) {
672 err = mode;
673 break;
674 }
675
676 if (put_user(mode, (u8 __user *) optval))
677 err =
-EFAULT;
678 break;
679
680 default:
681 err = -ENOPROTOOPT;
682 break;
683 }
684
685 release_sock(sk);
686 return err;
687 }
688
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org