From mboxrd@z Thu Jan 1 00:00:00 1970 From: Steven Rostedt Subject: kobject_register needs return value checks (was: What protection does sysfs_readdir have with SMP/Preemption?) Date: Wed, 23 Nov 2005 10:24:32 -0500 Message-ID: <1132759472.13395.65.camel@localhost.localdomain> References: <1132695202.13395.15.camel@localhost.localdomain> <20051122213947.GB8575@kroah.com> <20051123045049.GA22714@in.ibm.com> <20051123135847.GF22714@in.ibm.com> <1132755344.13395.32.camel@localhost.localdomain> <1132755654.13395.37.camel@localhost.localdomain> Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1132755654.13395.37.camel@localhost.localdomain> Sender: linux-kernel-owner@vger.kernel.org To: maneesh@in.ibm.com Cc: Thibaut VARENE , linux-scsi@vger.kernel.org, linuxraid@amcc.com, Matt Tolentino , len.brown@intel.com, Ingo Molnar , LKML , Greg KH List-Id: linux-scsi@vger.kernel.org I'm doing some tests to see what happens on a failure of setting up something in the sysfs, and I've discovered a few areas that don't test the return value of kobject_register. The test was due to a memory problem in a custom kernel that showed that sysfs didn't quite handle the error cases well. I did the following command: find . -name "*.c" ! -type d | xargs grep "kobject_register" I found 27 hits. Of these: 14 - checked the return value. 1 - reference in .mod.c file /* ignore it */ 3 - in comments /* ignore it */ 1 - declaration of actual function /* ignore it */ 1 - EXPORT_SYMBOL /* ignore it */ 1 - inside a printk quote. /* ignore it */ and ... 6 - calls without checking return values. Here are the culprits: ./drivers/acpi/scan.c: kobject_register(&device->kobj); ./drivers/firmware/efivars.c: kobject_register(&new_efivar->kobj); ./drivers/md/md.c: kobject_register(&mddev->kobj); ./drivers/parisc/pdc_stable.c: kobject_register(&entry->kobj); ./fs/partitions/check.c: kobject_register(&p->kobj); ./kernel/params.c: kobject_register(&mk->kobj); Normally, these would not return errors, but in case they do, the kernel should be robust enough to handle it. I tried to CC all the maintainers of the above files. -- Steve