blob: 6a63b60cad52097ab47af3bc2378cadf0b1439f1 [file] [log] [blame]
From javier.martinez@collabora.co.uk Thu Jun 6 03:26:24 2013
From: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
Date: Thu, 6 Jun 2013 12:25:49 +0200
Subject: [PATCH 1/6] net: bus: fix -EADDRINUSE reply for BUS_{ADD,DEL}_ADDR setsockopt
To: Greg KH <gregkh@linuxfoundation.org>
Cc: ltsi-dev@lists.linuxfoundation.org, Alban Crequy <alban.crequy@collabora.co.uk>
Message-ID: <1370514354-19114-2-git-send-email-javier.martinez@collabora.co.uk>
From: Alban Crequy <alban.crequy@collabora.co.uk>
When calling BUS_ADD_ADDR and BUS_DEL_ADDR set socket options
the kernel replied with a -EADDRINUSE "Address already in use"
error even when the address is not used.
This is because the buffer given to setsockopt was expected by
kernel to be a struct bus_addr while the AF_BUS documentation
says that it has to be a struct sockaddr_bus.
Signed-off-by: Alban Crequy <alban.crequy@collabora.co.uk>
---
net/bus/af_bus.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
--- a/net/bus/af_bus.c
+++ b/net/bus/af_bus.c
@@ -2331,7 +2331,7 @@ sock_put_out:
static int bus_setsockopt(struct socket *sock, int level, int optname,
char __user *optval, unsigned int optlen)
{
- struct bus_addr addr;
+ struct sockaddr_bus addr;
int res;
int val;
@@ -2341,19 +2341,24 @@ static int bus_setsockopt(struct socket
switch (optname) {
case BUS_ADD_ADDR:
case BUS_DEL_ADDR:
- if (optlen < sizeof(struct bus_addr))
+ if (optlen < sizeof(struct sockaddr_bus))
return -EINVAL;
if (!bus_sk(sock->sk)->bus_master_side)
return -EINVAL;
- if (copy_from_user(&addr, optval, sizeof(struct bus_addr)))
+ if (copy_from_user(&addr, optval, sizeof(struct sockaddr_bus)))
return -EFAULT;
+ if (addr.sbus_family != AF_BUS)
+ return -EINVAL;
+
if (optname == BUS_ADD_ADDR)
- res = bus_add_addr(bus_peer_get(sock->sk), &addr);
+ res = bus_add_addr(bus_peer_get(sock->sk),
+ &addr.sbus_addr);
else
- res = bus_del_addr(bus_peer_get(sock->sk), &addr);
+ res = bus_del_addr(bus_peer_get(sock->sk),
+ &addr.sbus_addr);
break;
case BUS_JOIN_BUS:
res = bus_join_bus(sock->sk);