Skip to contentSkip to conversation

devpts/inode.c : Fix Possible dentry NULL dereference

PATCH NAK Maninder Singh 3 participants 3 messages May 21, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 devpts/inode.c : Fix Possible dentry NULL dereference

EP-F6AA0618C49C4AEDA73BFF1B39950BAB

Hi,

Subject: [PATCH 1/1] devpts/inode.c : Fix Possible dentry NULL dereference

Issue reported by static tool Analyzer (Prevent). d_find_alias can return NULL to deentry, Thus we need NULL check before calling d_delete(dentry)

---
 fs/devpts/inode.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
fs/devpts/inode.c +2 -1
index add5663..0350ac2 100644
@@ -663,7 +663,8 @@ void devpts_pty_kill(struct inode *inode)
 	dentry = d_find_alias(inode);
 
 	drop_nlink(inode);
-	d_delete(dentry);
+	if (dentry)
+		d_delete(dentry);
 	dput(dentry);	/* d_alloc_name() in devpts_pty_new() */
 	dput(dentry);		/* d_find_alias above */
 
Signature · 4 lines
1.7.1

Thanks ,
Maninder Singhÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ¥Šwÿº{.nÇ+‰·¥Š{±þG«�éÿŠ{ayºʇڙë,j­¢f£¢·hš�ï�êÿ‘êçz_è®(­éšŽŠÝ¢j"�ú¶m§ÿÿ¾«þG«�éÿ¢¸?™¨è­Ú&£ø§~�á¶iO•æ¬z·švØ^¶m§ÿÿÃÿ¶ìÿ¢¸?–I¥
#1 lore raw
Quoted 2 lines · Maninder Singh

EP-F6AA0618C49C4AEDA73BFF1B39950BAB

What is this?

Quoted 19 lines

Hi,

Subject: [PATCH 1/1] devpts/inode.c : Fix Possible dentry NULL dereference

Issue reported by static tool Analyzer (Prevent). d_find_alias can return NULL to deentry, Thus we need NULL check before calling d_delete(dentry)

---
 fs/devpts/inode.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
fs/devpts/inode.c +0 -0
index add5663..0350ac2 100644

fs/devpts/inode.c void devpts_pty_kill(struct inode *inode) · line 669

Quoted 8 lines
fs/devpts/inode.c +2 -1
@@ -663,7 +663,8 @@ void devpts_pty_kill(struct inode *inode)
        dentry = d_find_alias(inode);
 
        drop_nlink(inode);
-       d_delete(dentry);
+       if (dentry)
+               d_delete(dentry);
        dput(dentry);   /* d_alloc_name() in devpts_pty_new() */
        dput(dentry);           /* d_find_alias above */

While it is correct that d_find_alias() may return NULL, can this also happen here?
I mean if that happens in the kill path we might have bigger trouble...

Al?

Signature · 2 lines
Thanks,
//richard
#2 lore raw
In reply to Maninder Singh
Quoted 5 lines · Maninder Singh

Subject: [PATCH 1/1] devpts/inode.c : Fix Possible dentry NULL dereference

Issue reported by static tool Analyzer (Prevent). d_find_alias can return NULL to deentry, Thus we need NULL check before calling d_delete(dentry)

No, we do not. That inode must have come from devpts_pty_new() and it wouldn't have made it out of there without having a dentry attached to it (and pinned).

NAK.