Commit c277c852 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] sparse: bluetooth annotation

parent f9280acd
...@@ -498,11 +498,11 @@ static int hci_uart_tty_ioctl(struct tty_struct *tty, struct file * file, ...@@ -498,11 +498,11 @@ static int hci_uart_tty_ioctl(struct tty_struct *tty, struct file * file,
/* /*
* We don't provide read/write/poll interface for user space. * We don't provide read/write/poll interface for user space.
*/ */
static ssize_t hci_uart_tty_read(struct tty_struct *tty, struct file *file, unsigned char *buf, size_t nr) static ssize_t hci_uart_tty_read(struct tty_struct *tty, struct file *file, unsigned char __user *buf, size_t nr)
{ {
return 0; return 0;
} }
static ssize_t hci_uart_tty_write(struct tty_struct *tty, struct file *file, const unsigned char *data, size_t count) static ssize_t hci_uart_tty_write(struct tty_struct *tty, struct file *file, const unsigned char __user *data, size_t count)
{ {
return 0; return 0;
} }
......
...@@ -127,7 +127,7 @@ static unsigned int hci_vhci_chr_poll(struct file *file, poll_table * wait) ...@@ -127,7 +127,7 @@ static unsigned int hci_vhci_chr_poll(struct file *file, poll_table * wait)
} }
/* Get packet from user space buffer(already verified) */ /* Get packet from user space buffer(already verified) */
static inline ssize_t hci_vhci_get_user(struct hci_vhci_struct *hci_vhci, const char *buf, size_t count) static inline ssize_t hci_vhci_get_user(struct hci_vhci_struct *hci_vhci, const char __user *buf, size_t count)
{ {
struct sk_buff *skb; struct sk_buff *skb;
...@@ -152,7 +152,7 @@ static inline ssize_t hci_vhci_get_user(struct hci_vhci_struct *hci_vhci, const ...@@ -152,7 +152,7 @@ static inline ssize_t hci_vhci_get_user(struct hci_vhci_struct *hci_vhci, const
} }
/* Write */ /* Write */
static ssize_t hci_vhci_chr_write(struct file * file, const char * buf, static ssize_t hci_vhci_chr_write(struct file * file, const char __user * buf,
size_t count, loff_t *pos) size_t count, loff_t *pos)
{ {
struct hci_vhci_struct *hci_vhci = (struct hci_vhci_struct *) file->private_data; struct hci_vhci_struct *hci_vhci = (struct hci_vhci_struct *) file->private_data;
...@@ -165,10 +165,11 @@ static ssize_t hci_vhci_chr_write(struct file * file, const char * buf, ...@@ -165,10 +165,11 @@ static ssize_t hci_vhci_chr_write(struct file * file, const char * buf,
/* Put packet to user space buffer(already verified) */ /* Put packet to user space buffer(already verified) */
static inline ssize_t hci_vhci_put_user(struct hci_vhci_struct *hci_vhci, static inline ssize_t hci_vhci_put_user(struct hci_vhci_struct *hci_vhci,
struct sk_buff *skb, char *buf, int count) struct sk_buff *skb, char __user *buf,
int count)
{ {
int len = count, total = 0; int len = count, total = 0;
char *ptr = buf; char __user *ptr = buf;
len = min_t(unsigned int, skb->len, len); len = min_t(unsigned int, skb->len, len);
if (copy_to_user(ptr, skb->data, len)) if (copy_to_user(ptr, skb->data, len))
...@@ -194,7 +195,7 @@ static inline ssize_t hci_vhci_put_user(struct hci_vhci_struct *hci_vhci, ...@@ -194,7 +195,7 @@ static inline ssize_t hci_vhci_put_user(struct hci_vhci_struct *hci_vhci,
} }
/* Read */ /* Read */
static ssize_t hci_vhci_chr_read(struct file * file, char * buf, size_t count, loff_t *pos) static ssize_t hci_vhci_chr_read(struct file * file, char __user * buf, size_t count, loff_t *pos)
{ {
struct hci_vhci_struct *hci_vhci = (struct hci_vhci_struct *) file->private_data; struct hci_vhci_struct *hci_vhci = (struct hci_vhci_struct *) file->private_data;
DECLARE_WAITQUEUE(wait, current); DECLARE_WAITQUEUE(wait, current);
......
...@@ -358,12 +358,12 @@ int hci_dev_open(__u16 dev); ...@@ -358,12 +358,12 @@ int hci_dev_open(__u16 dev);
int hci_dev_close(__u16 dev); int hci_dev_close(__u16 dev);
int hci_dev_reset(__u16 dev); int hci_dev_reset(__u16 dev);
int hci_dev_reset_stat(__u16 dev); int hci_dev_reset_stat(__u16 dev);
int hci_dev_cmd(unsigned int cmd, unsigned long arg); int hci_dev_cmd(unsigned int cmd, void __user *arg);
int hci_get_dev_list(unsigned long arg); int hci_get_dev_list(void __user *arg);
int hci_get_dev_info(unsigned long arg); int hci_get_dev_info(void __user *arg);
int hci_get_conn_list(unsigned long arg); int hci_get_conn_list(void __user *arg);
int hci_get_conn_info(struct hci_dev *hdev, unsigned long arg); int hci_get_conn_info(struct hci_dev *hdev, void __user *arg);
int hci_inquiry(unsigned long arg); int hci_inquiry(void __user *arg);
void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb); void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb);
......
...@@ -348,7 +348,7 @@ struct rfcomm_dev_list_req { ...@@ -348,7 +348,7 @@ struct rfcomm_dev_list_req {
struct rfcomm_dev_info dev_info[0]; struct rfcomm_dev_info dev_info[0];
}; };
int rfcomm_dev_ioctl(struct sock *sk, unsigned int cmd, unsigned long arg); int rfcomm_dev_ioctl(struct sock *sk, unsigned int cmd, void __user *arg);
int rfcomm_init_ttys(void); int rfcomm_init_ttys(void);
void rfcomm_cleanup_ttys(void); void rfcomm_cleanup_ttys(void);
......
...@@ -77,6 +77,7 @@ static int bnep_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long ...@@ -77,6 +77,7 @@ static int bnep_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long
struct bnep_conndel_req cd; struct bnep_conndel_req cd;
struct bnep_conninfo ci; struct bnep_conninfo ci;
struct socket *nsock; struct socket *nsock;
void __user *argp = (void __user *)arg;
int err; int err;
BT_DBG("cmd %x arg %lx", cmd, arg); BT_DBG("cmd %x arg %lx", cmd, arg);
...@@ -86,7 +87,7 @@ static int bnep_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long ...@@ -86,7 +87,7 @@ static int bnep_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long
if (!capable(CAP_NET_ADMIN)) if (!capable(CAP_NET_ADMIN))
return -EACCES; return -EACCES;
if (copy_from_user(&ca, (void *) arg, sizeof(ca))) if (copy_from_user(&ca, argp, sizeof(ca)))
return -EFAULT; return -EFAULT;
nsock = sockfd_lookup(ca.sock, &err); nsock = sockfd_lookup(ca.sock, &err);
...@@ -100,7 +101,7 @@ static int bnep_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long ...@@ -100,7 +101,7 @@ static int bnep_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long
err = bnep_add_connection(&ca, nsock); err = bnep_add_connection(&ca, nsock);
if (!err) { if (!err) {
if (copy_to_user((void *) arg, &ca, sizeof(ca))) if (copy_to_user(argp, &ca, sizeof(ca)))
err = -EFAULT; err = -EFAULT;
} else } else
fput(nsock->file); fput(nsock->file);
...@@ -111,30 +112,30 @@ static int bnep_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long ...@@ -111,30 +112,30 @@ static int bnep_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long
if (!capable(CAP_NET_ADMIN)) if (!capable(CAP_NET_ADMIN))
return -EACCES; return -EACCES;
if (copy_from_user(&cd, (void *) arg, sizeof(cd))) if (copy_from_user(&cd, argp, sizeof(cd)))
return -EFAULT; return -EFAULT;
return bnep_del_connection(&cd); return bnep_del_connection(&cd);
case BNEPGETCONNLIST: case BNEPGETCONNLIST:
if (copy_from_user(&cl, (void *) arg, sizeof(cl))) if (copy_from_user(&cl, argp, sizeof(cl)))
return -EFAULT; return -EFAULT;
if (cl.cnum <= 0) if (cl.cnum <= 0)
return -EINVAL; return -EINVAL;
err = bnep_get_connlist(&cl); err = bnep_get_connlist(&cl);
if (!err && copy_to_user((void *) arg, &cl, sizeof(cl))) if (!err && copy_to_user(argp, &cl, sizeof(cl)))
return -EFAULT; return -EFAULT;
return err; return err;
case BNEPGETCONNINFO: case BNEPGETCONNINFO:
if (copy_from_user(&ci, (void *) arg, sizeof(ci))) if (copy_from_user(&ci, argp, sizeof(ci)))
return -EFAULT; return -EFAULT;
err = bnep_get_conninfo(&ci); err = bnep_get_conninfo(&ci);
if (!err && copy_to_user((void *) arg, &ci, sizeof(ci))) if (!err && copy_to_user(argp, &ci, sizeof(ci)))
return -EFAULT; return -EFAULT;
return err; return err;
......
...@@ -55,7 +55,7 @@ struct cmtp_conninfo { ...@@ -55,7 +55,7 @@ struct cmtp_conninfo {
struct cmtp_connlist_req { struct cmtp_connlist_req {
__u32 cnum; __u32 cnum;
struct cmtp_conninfo *ci; struct cmtp_conninfo __user *ci;
}; };
int cmtp_add_connection(struct cmtp_connadd_req *req, struct socket *sock); int cmtp_add_connection(struct cmtp_connadd_req *req, struct socket *sock);
......
...@@ -71,6 +71,7 @@ static int cmtp_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long ...@@ -71,6 +71,7 @@ static int cmtp_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long
struct cmtp_connlist_req cl; struct cmtp_connlist_req cl;
struct cmtp_conninfo ci; struct cmtp_conninfo ci;
struct socket *nsock; struct socket *nsock;
void __user *argp = (void __user *)arg;
int err; int err;
BT_DBG("cmd %x arg %lx", cmd, arg); BT_DBG("cmd %x arg %lx", cmd, arg);
...@@ -80,7 +81,7 @@ static int cmtp_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long ...@@ -80,7 +81,7 @@ static int cmtp_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long
if (!capable(CAP_NET_ADMIN)) if (!capable(CAP_NET_ADMIN))
return -EACCES; return -EACCES;
if (copy_from_user(&ca, (void *) arg, sizeof(ca))) if (copy_from_user(&ca, argp, sizeof(ca)))
return -EFAULT; return -EFAULT;
nsock = sockfd_lookup(ca.sock, &err); nsock = sockfd_lookup(ca.sock, &err);
...@@ -94,7 +95,7 @@ static int cmtp_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long ...@@ -94,7 +95,7 @@ static int cmtp_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long
err = cmtp_add_connection(&ca, nsock); err = cmtp_add_connection(&ca, nsock);
if (!err) { if (!err) {
if (copy_to_user((void *) arg, &ca, sizeof(ca))) if (copy_to_user(argp, &ca, sizeof(ca)))
err = -EFAULT; err = -EFAULT;
} else } else
fput(nsock->file); fput(nsock->file);
...@@ -105,30 +106,30 @@ static int cmtp_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long ...@@ -105,30 +106,30 @@ static int cmtp_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long
if (!capable(CAP_NET_ADMIN)) if (!capable(CAP_NET_ADMIN))
return -EACCES; return -EACCES;
if (copy_from_user(&cd, (void *) arg, sizeof(cd))) if (copy_from_user(&cd, argp, sizeof(cd)))
return -EFAULT; return -EFAULT;
return cmtp_del_connection(&cd); return cmtp_del_connection(&cd);
case CMTPGETCONNLIST: case CMTPGETCONNLIST:
if (copy_from_user(&cl, (void *) arg, sizeof(cl))) if (copy_from_user(&cl, argp, sizeof(cl)))
return -EFAULT; return -EFAULT;
if (cl.cnum <= 0) if (cl.cnum <= 0)
return -EINVAL; return -EINVAL;
err = cmtp_get_connlist(&cl); err = cmtp_get_connlist(&cl);
if (!err && copy_to_user((void *) arg, &cl, sizeof(cl))) if (!err && copy_to_user(argp, &cl, sizeof(cl)))
return -EFAULT; return -EFAULT;
return err; return err;
case CMTPGETCONNINFO: case CMTPGETCONNINFO:
if (copy_from_user(&ci, (void *) arg, sizeof(ci))) if (copy_from_user(&ci, argp, sizeof(ci)))
return -EFAULT; return -EFAULT;
err = cmtp_get_conninfo(&ci); err = cmtp_get_conninfo(&ci);
if (!err && copy_to_user((void *) arg, &ci, sizeof(ci))) if (!err && copy_to_user(argp, &ci, sizeof(ci)))
return -EFAULT; return -EFAULT;
return err; return err;
......
...@@ -353,7 +353,7 @@ void hci_conn_hash_flush(struct hci_dev *hdev) ...@@ -353,7 +353,7 @@ void hci_conn_hash_flush(struct hci_dev *hdev)
} }
} }
int hci_get_conn_list(unsigned long arg) int hci_get_conn_list(void __user *arg)
{ {
struct hci_conn_list_req req, *cl; struct hci_conn_list_req req, *cl;
struct hci_conn_info *ci; struct hci_conn_info *ci;
...@@ -361,7 +361,7 @@ int hci_get_conn_list(unsigned long arg) ...@@ -361,7 +361,7 @@ int hci_get_conn_list(unsigned long arg)
struct list_head *p; struct list_head *p;
int n = 0, size, err; int n = 0, size, err;
if (copy_from_user(&req, (void *) arg, sizeof(req))) if (copy_from_user(&req, arg, sizeof(req)))
return -EFAULT; return -EFAULT;
if (!req.conn_num || req.conn_num > (PAGE_SIZE * 2) / sizeof(*ci)) if (!req.conn_num || req.conn_num > (PAGE_SIZE * 2) / sizeof(*ci))
...@@ -401,20 +401,20 @@ int hci_get_conn_list(unsigned long arg) ...@@ -401,20 +401,20 @@ int hci_get_conn_list(unsigned long arg)
hci_dev_put(hdev); hci_dev_put(hdev);
err = copy_to_user((void *) arg, cl, size); err = copy_to_user(arg, cl, size);
kfree(cl); kfree(cl);
return err ? -EFAULT : 0; return err ? -EFAULT : 0;
} }
int hci_get_conn_info(struct hci_dev *hdev, unsigned long arg) int hci_get_conn_info(struct hci_dev *hdev, void __user *arg)
{ {
struct hci_conn_info_req req; struct hci_conn_info_req req;
struct hci_conn_info ci; struct hci_conn_info ci;
struct hci_conn *conn; struct hci_conn *conn;
char *ptr = (void *) arg + sizeof(req); char __user *ptr = arg + sizeof(req);
if (copy_from_user(&req, (void *) arg, sizeof(req))) if (copy_from_user(&req, arg, sizeof(req)))
return -EFAULT; return -EFAULT;
hci_dev_lock_bh(hdev); hci_dev_lock_bh(hdev);
......
...@@ -366,15 +366,15 @@ static void hci_inq_req(struct hci_dev *hdev, unsigned long opt) ...@@ -366,15 +366,15 @@ static void hci_inq_req(struct hci_dev *hdev, unsigned long opt)
hci_send_cmd(hdev, OGF_LINK_CTL, OCF_INQUIRY, sizeof(cp), &cp); hci_send_cmd(hdev, OGF_LINK_CTL, OCF_INQUIRY, sizeof(cp), &cp);
} }
int hci_inquiry(unsigned long arg) int hci_inquiry(void __user *arg)
{ {
__u8 __user *ptr = arg;
struct hci_inquiry_req ir; struct hci_inquiry_req ir;
struct hci_dev *hdev; struct hci_dev *hdev;
int err = 0, do_inquiry = 0, max_rsp; int err = 0, do_inquiry = 0, max_rsp;
long timeo; long timeo;
__u8 *buf, *ptr; __u8 *buf;
ptr = (void *) arg;
if (copy_from_user(&ir, ptr, sizeof(ir))) if (copy_from_user(&ir, ptr, sizeof(ir)))
return -EFAULT; return -EFAULT;
...@@ -616,13 +616,13 @@ int hci_dev_reset_stat(__u16 dev) ...@@ -616,13 +616,13 @@ int hci_dev_reset_stat(__u16 dev)
return ret; return ret;
} }
int hci_dev_cmd(unsigned int cmd, unsigned long arg) int hci_dev_cmd(unsigned int cmd, void __user *arg)
{ {
struct hci_dev *hdev; struct hci_dev *hdev;
struct hci_dev_req dr; struct hci_dev_req dr;
int err = 0; int err = 0;
if (copy_from_user(&dr, (void *) arg, sizeof(dr))) if (copy_from_user(&dr, arg, sizeof(dr)))
return -EFAULT; return -EFAULT;
if (!(hdev = hci_dev_get(dr.dev_id))) if (!(hdev = hci_dev_get(dr.dev_id)))
...@@ -685,7 +685,7 @@ int hci_dev_cmd(unsigned int cmd, unsigned long arg) ...@@ -685,7 +685,7 @@ int hci_dev_cmd(unsigned int cmd, unsigned long arg)
return err; return err;
} }
int hci_get_dev_list(unsigned long arg) int hci_get_dev_list(void __user *arg)
{ {
struct hci_dev_list_req *dl; struct hci_dev_list_req *dl;
struct hci_dev_req *dr; struct hci_dev_req *dr;
...@@ -693,7 +693,7 @@ int hci_get_dev_list(unsigned long arg) ...@@ -693,7 +693,7 @@ int hci_get_dev_list(unsigned long arg)
int n = 0, size, err; int n = 0, size, err;
__u16 dev_num; __u16 dev_num;
if (get_user(dev_num, (__u16 *) arg)) if (get_user(dev_num, (__u16 __user *) arg))
return -EFAULT; return -EFAULT;
if (!dev_num || dev_num > (PAGE_SIZE * 2) / sizeof(*dr)) if (!dev_num || dev_num > (PAGE_SIZE * 2) / sizeof(*dr))
...@@ -720,19 +720,19 @@ int hci_get_dev_list(unsigned long arg) ...@@ -720,19 +720,19 @@ int hci_get_dev_list(unsigned long arg)
dl->dev_num = n; dl->dev_num = n;
size = sizeof(*dl) + n * sizeof(*dr); size = sizeof(*dl) + n * sizeof(*dr);
err = copy_to_user((void *) arg, dl, size); err = copy_to_user(arg, dl, size);
kfree(dl); kfree(dl);
return err ? -EFAULT : 0; return err ? -EFAULT : 0;
} }
int hci_get_dev_info(unsigned long arg) int hci_get_dev_info(void __user *arg)
{ {
struct hci_dev *hdev; struct hci_dev *hdev;
struct hci_dev_info di; struct hci_dev_info di;
int err = 0; int err = 0;
if (copy_from_user(&di, (void *) arg, sizeof(di))) if (copy_from_user(&di, arg, sizeof(di)))
return -EFAULT; return -EFAULT;
if (!(hdev = hci_dev_get(di.dev_id))) if (!(hdev = hci_dev_get(di.dev_id)))
...@@ -753,7 +753,7 @@ int hci_get_dev_info(unsigned long arg) ...@@ -753,7 +753,7 @@ int hci_get_dev_info(unsigned long arg)
memcpy(&di.stat, &hdev->stat, sizeof(di.stat)); memcpy(&di.stat, &hdev->stat, sizeof(di.stat));
memcpy(&di.features, &hdev->features, sizeof(di.features)); memcpy(&di.features, &hdev->features, sizeof(di.features));
if (copy_to_user((void *) arg, &di, sizeof(di))) if (copy_to_user(arg, &di, sizeof(di)))
err = -EFAULT; err = -EFAULT;
hci_dev_put(hdev); hci_dev_put(hdev);
......
...@@ -186,7 +186,7 @@ static inline int hci_sock_bound_ioctl(struct sock *sk, unsigned int cmd, unsign ...@@ -186,7 +186,7 @@ static inline int hci_sock_bound_ioctl(struct sock *sk, unsigned int cmd, unsign
return 0; return 0;
case HCIGETCONNINFO: case HCIGETCONNINFO:
return hci_get_conn_info(hdev, arg); return hci_get_conn_info(hdev, (void __user *)arg);
default: default:
if (hdev->ioctl) if (hdev->ioctl)
...@@ -198,19 +198,20 @@ static inline int hci_sock_bound_ioctl(struct sock *sk, unsigned int cmd, unsign ...@@ -198,19 +198,20 @@ static inline int hci_sock_bound_ioctl(struct sock *sk, unsigned int cmd, unsign
static int hci_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) static int hci_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
{ {
struct sock *sk = sock->sk; struct sock *sk = sock->sk;
void __user *argp = (void __user *)arg;
int err; int err;
BT_DBG("cmd %x arg %lx", cmd, arg); BT_DBG("cmd %x arg %lx", cmd, arg);
switch (cmd) { switch (cmd) {
case HCIGETDEVLIST: case HCIGETDEVLIST:
return hci_get_dev_list(arg); return hci_get_dev_list(argp);
case HCIGETDEVINFO: case HCIGETDEVINFO:
return hci_get_dev_info(arg); return hci_get_dev_info(argp);
case HCIGETCONNLIST: case HCIGETCONNLIST:
return hci_get_conn_list(arg); return hci_get_conn_list(argp);
case HCIDEVUP: case HCIDEVUP:
if (!capable(CAP_NET_ADMIN)) if (!capable(CAP_NET_ADMIN))
...@@ -242,10 +243,10 @@ static int hci_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long a ...@@ -242,10 +243,10 @@ static int hci_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long a
case HCISETSCOMTU: case HCISETSCOMTU:
if (!capable(CAP_NET_ADMIN)) if (!capable(CAP_NET_ADMIN))
return -EACCES; return -EACCES;
return hci_dev_cmd(cmd, arg); return hci_dev_cmd(cmd, argp);
case HCIINQUIRY: case HCIINQUIRY:
return hci_inquiry(arg); return hci_inquiry(argp);
default: default:
lock_sock(sk); lock_sock(sk);
......
...@@ -707,7 +707,7 @@ static int rfcomm_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned lon ...@@ -707,7 +707,7 @@ static int rfcomm_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned lon
lock_sock(sk); lock_sock(sk);
#ifdef CONFIG_BT_RFCOMM_TTY #ifdef CONFIG_BT_RFCOMM_TTY
err = rfcomm_dev_ioctl(sk, cmd, arg); err = rfcomm_dev_ioctl(sk, cmd, (void __user *)arg);
#else #else
err = -EOPNOTSUPP; err = -EOPNOTSUPP;
#endif #endif
......
...@@ -302,13 +302,13 @@ static struct sk_buff *rfcomm_wmalloc(struct rfcomm_dev *dev, unsigned long size ...@@ -302,13 +302,13 @@ static struct sk_buff *rfcomm_wmalloc(struct rfcomm_dev *dev, unsigned long size
#define NOCAP_FLAGS ((1 << RFCOMM_REUSE_DLC) | (1 << RFCOMM_RELEASE_ONHUP)) #define NOCAP_FLAGS ((1 << RFCOMM_REUSE_DLC) | (1 << RFCOMM_RELEASE_ONHUP))
static int rfcomm_create_dev(struct sock *sk, unsigned long arg) static int rfcomm_create_dev(struct sock *sk, void __user *arg)
{ {
struct rfcomm_dev_req req; struct rfcomm_dev_req req;
struct rfcomm_dlc *dlc; struct rfcomm_dlc *dlc;
int id; int id;
if (copy_from_user(&req, (void *) arg, sizeof(req))) if (copy_from_user(&req, arg, sizeof(req)))
return -EFAULT; return -EFAULT;
BT_DBG("sk %p dev_id %id flags 0x%x", sk, req.dev_id, req.flags); BT_DBG("sk %p dev_id %id flags 0x%x", sk, req.dev_id, req.flags);
...@@ -344,12 +344,12 @@ static int rfcomm_create_dev(struct sock *sk, unsigned long arg) ...@@ -344,12 +344,12 @@ static int rfcomm_create_dev(struct sock *sk, unsigned long arg)
return id; return id;
} }
static int rfcomm_release_dev(unsigned long arg) static int rfcomm_release_dev(void __user *arg)
{ {
struct rfcomm_dev_req req; struct rfcomm_dev_req req;
struct rfcomm_dev *dev; struct rfcomm_dev *dev;
if (copy_from_user(&req, (void *) arg, sizeof(req))) if (copy_from_user(&req, arg, sizeof(req)))
return -EFAULT; return -EFAULT;
BT_DBG("dev_id %id flags 0x%x", req.dev_id, req.flags); BT_DBG("dev_id %id flags 0x%x", req.dev_id, req.flags);
...@@ -370,7 +370,7 @@ static int rfcomm_release_dev(unsigned long arg) ...@@ -370,7 +370,7 @@ static int rfcomm_release_dev(unsigned long arg)
return 0; return 0;
} }
static int rfcomm_get_dev_list(unsigned long arg) static int rfcomm_get_dev_list(void __user *arg)
{ {
struct rfcomm_dev_list_req *dl; struct rfcomm_dev_list_req *dl;
struct rfcomm_dev_info *di; struct rfcomm_dev_info *di;
...@@ -380,7 +380,7 @@ static int rfcomm_get_dev_list(unsigned long arg) ...@@ -380,7 +380,7 @@ static int rfcomm_get_dev_list(unsigned long arg)
BT_DBG(""); BT_DBG("");
if (get_user(dev_num, (u16 *) arg)) if (get_user(dev_num, (u16 __user *) arg))
return -EFAULT; return -EFAULT;
if (!dev_num || dev_num > (PAGE_SIZE * 4) / sizeof(*di)) if (!dev_num || dev_num > (PAGE_SIZE * 4) / sizeof(*di))
...@@ -412,13 +412,13 @@ static int rfcomm_get_dev_list(unsigned long arg) ...@@ -412,13 +412,13 @@ static int rfcomm_get_dev_list(unsigned long arg)
dl->dev_num = n; dl->dev_num = n;
size = sizeof(*dl) + n * sizeof(*di); size = sizeof(*dl) + n * sizeof(*di);
err = copy_to_user((void *) arg, dl, size); err = copy_to_user(arg, dl, size);
kfree(dl); kfree(dl);
return err ? -EFAULT : 0; return err ? -EFAULT : 0;
} }
static int rfcomm_get_dev_info(unsigned long arg) static int rfcomm_get_dev_info(void __user *arg)
{ {
struct rfcomm_dev *dev; struct rfcomm_dev *dev;
struct rfcomm_dev_info di; struct rfcomm_dev_info di;
...@@ -426,7 +426,7 @@ static int rfcomm_get_dev_info(unsigned long arg) ...@@ -426,7 +426,7 @@ static int rfcomm_get_dev_info(unsigned long arg)
BT_DBG(""); BT_DBG("");
if (copy_from_user(&di, (void *)arg, sizeof(di))) if (copy_from_user(&di, arg, sizeof(di)))
return -EFAULT; return -EFAULT;
if (!(dev = rfcomm_dev_get(di.id))) if (!(dev = rfcomm_dev_get(di.id)))
...@@ -438,16 +438,16 @@ static int rfcomm_get_dev_info(unsigned long arg) ...@@ -438,16 +438,16 @@ static int rfcomm_get_dev_info(unsigned long arg)
bacpy(&di.src, &dev->src); bacpy(&di.src, &dev->src);
bacpy(&di.dst, &dev->dst); bacpy(&di.dst, &dev->dst);
if (copy_to_user((void *)arg, &di, sizeof(di))) if (copy_to_user(arg, &di, sizeof(di)))
err = -EFAULT; err = -EFAULT;
rfcomm_dev_put(dev); rfcomm_dev_put(dev);
return err; return err;
} }
int rfcomm_dev_ioctl(struct sock *sk, unsigned int cmd, unsigned long arg) int rfcomm_dev_ioctl(struct sock *sk, unsigned int cmd, void __user *arg)
{ {
BT_DBG("cmd %d arg %ld", cmd, arg); BT_DBG("cmd %d arg %p", cmd, arg);
switch (cmd) { switch (cmd) {
case RFCOMMCREATEDEV: case RFCOMMCREATEDEV:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment