Bug 188751 - In function caif_sktinit_module(), the return value of sock_register() is incorrectly checked.
Summary: In function caif_sktinit_module(), the return value of sock_register() is inc...
Status: RESOLVED CODE_FIX
Alias: None
Product: Networking
Classification: Unclassified
Component: Other (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: Stephen Hemminger
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-11-25 10:54 UTC by bianpan
Modified: 2017-05-11 23:50 UTC (History)
0 users

See Also:
Kernel Version: linux-4.9-rc6
Subsystem:
Regression: No
Bisected commit-id:


Attachments
The patch fixes the bug (1.12 KB, patch)
2017-05-11 23:50 UTC, bianpan
Details | Diff

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.

Note You need to log in before you can comment on or make changes to this bug.