PROBLEM:there exists a wrong return value of function br_sysfs_addbr()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 Bug Description:    
    In function br_sysfs_addbr() at net/bridge/br_sysfs_br.c:line 851, return value "0" indicates success.
if function kobject_create_and_add() at line 871 fails, function br_sysfs_addbr() will return the value of variable "err", which is 0 because sysfs_create_bin_file() at line 864 succeeded previously.But, function br_sysfs_addbr() should propagate the error and return a negative number to its caller functions.

The related code snippets in br_sysfs_addbr are as following.
br_sysfs_addbr @@ net/bridge/br_sysfs_br.c:line 851

851 int br_sysfs_addbr(struct net_device *dev)
852 {
...
864 err = sysfs_create_bin_file(brobj, &bridge_forward);
865 if (err) {
866 pr_info("%s: can't create attribute file %s/%s\n",
867 __func__, dev->name, bridge_forward.attr.name);
868 goto out2;
869 }
870 
871 br->ifobj = kobject_create_and_add(SYSFS_BRIDGE_PORT_SUBDIR, brobj);
872 if (!br->ifobj) {
873 pr_info("%s: can't add kobject (directory) %s/%s\n",
874 __func__, dev->name, SYSFS_BRIDGE_PORT_SUBDIR);
875 goto out3;
876 }
877 return 0;
878  out3:
879 sysfs_remove_bin_file(&dev->dev.kobj, &bridge_forward);
880  out2:
881 sysfs_remove_group(&dev->dev.kobj, &bridge_group);
882  out1:
883 return err;
884 
885 }

Generally, when the call to kobject_create_and_add() fails, the return value of caller functions 
should be different from another return value set when the call to kobject_create_and_add() succeeds, 
like the following codes in another file.
kobject_create_and_add @@ arch/x86/kernel/cpu/mcheck/mce_amd.c:line 711
677 static int threshold_create_bank(unsigned int cpu, unsigned int bank)
678 {
 ...
711         b->kobj = kobject_create_and_add(name, &dev->kobj);
712         if (!b->kobj) {
713                 err = -EINVAL;
714                 goto out_free;
715         }
 ...
    }

Kernel version:4.5


 


[Index of Archives]     [Netdev]     [AoE Tools]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]     [Video 4 Linux]

  Powered by Linux