Re: [PATCH v2 1/8] Bluetooth: Refactor l2cap_sock_sendmsg() to copy user buffer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Jukka,

>>> diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
>>> index f59e00c..7e7b28a 100644
>>> --- a/net/bluetooth/l2cap_sock.c
>>> +++ b/net/bluetooth/l2cap_sock.c
>>> @@ -948,6 +948,7 @@ static int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
>>> {
>>> 	struct sock *sk = sock->sk;
>>> 	struct l2cap_chan *chan = l2cap_pi(sk)->chan;
>>> +	unsigned char *buf;
>>> 	int err;
>>> 
>>> 	BT_DBG("sock %p, sk %p", sock, sk);
>>> @@ -968,10 +969,21 @@ static int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
>>> 	if (err)
>>> 		return err;
>>> 
>>> +	buf = kmalloc(len, GFP_KERNEL);
>>> +	if (!buf)
>>> +		return -ENOMEM;
>>> +
>>> +	if (memcpy_fromiovec(buf, msg->msg_iov, len)) {
>>> +		err = -EFAULT;
>>> +		goto done;
>>> +	}
>>> +
>>> 	l2cap_chan_lock(chan);
>>> -	err = l2cap_chan_send(chan, msg, len, sk->sk_priority);
>>> +	err = l2cap_chan_send(chan, buf, len, sk->sk_priority, msg->msg_flags);
>>> 	l2cap_chan_unlock(chan);
>>> 
>>> +done:
>>> +	kfree(buf);
>>> 	return err;
>>> }
>> 
>> We don’t have to use chan->ops->alloc_skb here? Has this become obsolete now?
> 
> Isn't the buf here just a normal memory buffer that stores just the user
> data and has nothing to do with sk_buff that is returned by alloc_skb()?

I asked the question, because I do not know. Do we need alloc_skb callback at all.

Regards

Marcel

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux