diff mbox series

[net-next] net: socket: Fix missing break in switch statement

Message ID 20190424153124.GA9475@embeddedor
State Accepted
Delegated to: David Miller
Headers show
Series [net-next] net: socket: Fix missing break in switch statement | expand

Commit Message

Gustavo A. R. Silva April 24, 2019, 3:31 p.m. UTC
Add missing break statement in order to prevent the code from falling
through to cases SIOCGSTAMP_NEW and SIOCGSTAMPNS_NEW.

This bug was found thanks to the ongoing efforts to enable
-Wimplicit-fallthrough.

Fixes: 0768e17073dc ("net: socket: implement 64-bit timestamps")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
 net/socket.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Arnd Bergmann April 24, 2019, 6:45 p.m. UTC | #1
On Wed, Apr 24, 2019 at 5:33 PM Gustavo A. R. Silva
<gustavo@embeddedor.com> wrote:
>
> Add missing break statement in order to prevent the code from falling
> through to cases SIOCGSTAMP_NEW and SIOCGSTAMPNS_NEW.
>
> This bug was found thanks to the ongoing efforts to enable
> -Wimplicit-fallthrough.
>
> Fixes: 0768e17073dc ("net: socket: implement 64-bit timestamps")
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>

I had just prepared the same patch after Dan told me about the issue today,
but you managed to submit it first.

Thanks for the fix!

     Arnd
Gustavo A. R. Silva April 24, 2019, 7:47 p.m. UTC | #2
Arnd,

On 4/24/19 1:45 PM, Arnd Bergmann wrote:
> On Wed, Apr 24, 2019 at 5:33 PM Gustavo A. R. Silva
> <gustavo@embeddedor.com> wrote:
>>
>> Add missing break statement in order to prevent the code from falling
>> through to cases SIOCGSTAMP_NEW and SIOCGSTAMPNS_NEW.
>>
>> This bug was found thanks to the ongoing efforts to enable
>> -Wimplicit-fallthrough.
>>
>> Fixes: 0768e17073dc ("net: socket: implement 64-bit timestamps")
>> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> 
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

Just for clarification: Dan didn't report this to me. I found this
bug while working on the last fall-through warnings in net.

> Acked-by: Arnd Bergmann <arnd@arndb.de>
> 
> I had just prepared the same patch after Dan told me about the issue today,
> but you managed to submit it first.
> 
> Thanks for the fix!
> 

Glad to help. :)

Thanks
--
Gustavo
David Miller April 26, 2019, 3:29 p.m. UTC | #3
From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
Date: Wed, 24 Apr 2019 10:31:24 -0500

> Add missing break statement in order to prevent the code from falling
> through to cases SIOCGSTAMP_NEW and SIOCGSTAMPNS_NEW.
> 
> This bug was found thanks to the ongoing efforts to enable
> -Wimplicit-fallthrough.
> 
> Fixes: 0768e17073dc ("net: socket: implement 64-bit timestamps")
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>

Applied.
Gustavo A. R. Silva April 26, 2019, 3:45 p.m. UTC | #4
On 4/26/19 10:29 AM, David Miller wrote:
> From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
> Date: Wed, 24 Apr 2019 10:31:24 -0500
> 
>> Add missing break statement in order to prevent the code from falling
>> through to cases SIOCGSTAMP_NEW and SIOCGSTAMPNS_NEW.
>>
>> This bug was found thanks to the ongoing efforts to enable
>> -Wimplicit-fallthrough.
>>
>> Fixes: 0768e17073dc ("net: socket: implement 64-bit timestamps")
>> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> 
> Applied.
> 

Great. :)

Thanks, Dave.
--
Gustavo
diff mbox series

Patch

diff --git a/net/socket.c b/net/socket.c
index 8d9d4fc7d962..a180e1a9ff23 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -1173,6 +1173,7 @@  static long sock_ioctl(struct file *file, unsigned cmd, unsigned long arg)
 			err = sock->ops->gettstamp(sock, argp,
 						   cmd == SIOCGSTAMP_OLD,
 						   !IS_ENABLED(CONFIG_64BIT));
+			break;
 		case SIOCGSTAMP_NEW:
 		case SIOCGSTAMPNS_NEW:
 			if (!sock->ops->gettstamp) {