Bug 188751

Summary: In function caif_sktinit_module(), the return value of sock_register() is incorrectly checked.
Product: Networking Reporter: bianpan (bianpan2010)
Component: OtherAssignee: Stephen Hemminger (stephen)
Status: RESOLVED CODE_FIX    
Severity: normal    
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: linux-4.9-rc6 Subsystem:
Regression: No Bisected commit-id:
Attachments: The patch fixes the bug

Description bianpan 2016-11-25 10:54:28 UTC
Function sock_register() returns a negative integer on failure. In function caif_sktinit_module() defined in net/caif/caif_socket.c, the return value of sock_register() is checked. However, no matter whether the return value of sock_register() is zero, it will returns 0 (indicates success). I guess the symbol not "!" is a typo in the check statement at line 1111. Codes related to this bug are shown as below.

caif_sktinit_module @@ net/caif/caif_socket.c
1108 static int __init caif_sktinit_module(void)
1109 {
1110     int err = sock_register(&caif_family_ops);
1111     if (!err)     // use if(err) ?
1112         return err;
1113     return 0;
1114 }

Thanks very much!
Comment 1 bianpan 2017-05-11 23:50:42 UTC
Created attachment 256413 [details]
The patch fixes the bug

The patch has been merged into the latest version of the Linux kernel. So I will close the bug.