Skip to contentSkip to conversation

sysfs_drop_dentry(): possible NULL dereference

DISCUSSION Adrian Bunk 2 participants 2 messages Mar 19, 2007

lore
Share & tools
lore
#0 lore raw

The Coverity checker spotted the following incorrect part of commit 94bebf4d1b8e7719f0f3944c037a21cfd99a4af7:

<-- snip -->

...
void sysfs_drop_dentry(struct sysfs_dirent * sd, struct dentry * parent)

 {
        struct dentry * dentry = sd->s_dentry;

+ struct inode *inode;

        if (dentry) {
                spin_lock(&dcache_lock);
                spin_lock(&dentry->d_lock);
                if (!(d_unhashed(dentry) && dentry->d_inode)) {

+ inode = dentry->d_inode;
+ spin_lock(&inode->i_lock);
...

<-- snip -->

If (!dentry->d_inode), then it's a NULL dereference.

cu
Adrian

Signature · 4 lines
       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed
#1 lore raw

Am Montag, 19. März 2007 10:22 schrieb Adrian Bunk:

Quoted 13 lines

void sysfs_drop_dentry(struct sysfs_dirent * sd, struct dentry * parent)

 {
        struct dentry * dentry = sd->s_dentry;
(quoted diff) +3 -0
+       struct inode *inode;
 
        if (dentry) {
                spin_lock(&dcache_lock);
                spin_lock(&dentry->d_lock);
                if (!(d_unhashed(dentry) && dentry->d_inode)) {
+                       inode = dentry->d_inode;
+                       spin_lock(&inode->i_lock);
...
Quoted 3 lines

<-- snip -->

If (!dentry->d_inode), then it's a NULL dereference.

As far as I can tell, sysfs being a virtual filesystem, does not use dentries without inodes associated.

Regards
Oliver