From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christoph Paasch Subject: [PATCH] devinet_ioctl(): Set ret to 0 when breaking out of the switch-case Date: Sun, 28 Jan 2018 20:48:07 -0800 Message-ID: <20180129044807.46975-1-cpaasch@apple.com> Content-Transfer-Encoding: 7BIT Cc: netdev@vger.kernel.org, Al Viro , Christoph Hellwig To: David Miller Return-path: Received: from mail-out6.apple.com ([17.151.62.28]:45891 "EHLO mail-in6.apple.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751175AbeA2Eso (ORCPT ); Sun, 28 Jan 2018 23:48:44 -0500 Sender: netdev-owner@vger.kernel.org List-ID: Commit 03aef17bb79b ("devinet_ioctl(): take copyin/copyout to caller") introduced a regression when using ifconfig. ifconfig doesn't show the address anymore. The reason is that the above patch changed the flow in devinet_ioctl(), where we break; and end up returning ret. ret however is set to -EADDRNOTAVAIL, which later on prevents the copy_to_user() in inet_ioctl(). Thus, when we break in devinet_ioctl() we have to set ret to 0 to properly return out of devinet_ioctl. Cc: Al Viro Cc: Christoph Hellwig Fixes: 03aef17bb79b ("devinet_ioctl(): take copyin/copyout to caller") Signed-off-by: Christoph Paasch --- net/ipv4/devinet.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c index e056c0067f2c..942dbc73def0 100644 --- a/net/ipv4/devinet.c +++ b/net/ipv4/devinet.c @@ -1049,18 +1049,22 @@ int devinet_ioctl(struct net *net, unsigned int cmd, struct ifreq *ifr) switch (cmd) { case SIOCGIFADDR: /* Get interface address */ sin->sin_addr.s_addr = ifa->ifa_local; + ret = 0; break; case SIOCGIFBRDADDR: /* Get the broadcast address */ sin->sin_addr.s_addr = ifa->ifa_broadcast; + ret = 0; break; case SIOCGIFDSTADDR: /* Get the destination address */ sin->sin_addr.s_addr = ifa->ifa_address; + ret = 0; break; case SIOCGIFNETMASK: /* Get the netmask for the interface */ sin->sin_addr.s_addr = ifa->ifa_mask; + ret = 0; break; case SIOCSIFFLAGS: -- 2.16.1