Skip to content

Commit

Permalink
staging: vboxsf: fix dereference of pointer dentry before it is null …
Browse files Browse the repository at this point in the history
…checked

Currently the pointer dentry is being dereferenced before it is
being null checked.  Fix this by only dereferencing dentry once
we know it is not null.

Addresses-Coverity: ("Dereference before null check")
Fixes: df40286 ("staging: Add VirtualBox guest shared folder (vboxsf) support")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Link: https://lore.kernel.org/r/20191105175108.79824-1-colin.king@canonical.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Colin Ian King authored and Greg Kroah-Hartman committed Nov 7, 2019
1 parent 32e9f6c commit 94fed40
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/staging/vboxsf/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ int vboxsf_stat_dentry(struct dentry *dentry, struct shfl_fsobjinfo *info)

int vboxsf_inode_revalidate(struct dentry *dentry)
{
struct vboxsf_sbi *sbi = VBOXSF_SBI(dentry->d_sb);
struct vboxsf_sbi *sbi;
struct vboxsf_inode *sf_i;
struct shfl_fsobjinfo info;
struct timespec64 prev_mtime;
Expand All @@ -187,6 +187,7 @@ int vboxsf_inode_revalidate(struct dentry *dentry)
inode = d_inode(dentry);
prev_mtime = inode->i_mtime;
sf_i = VBOXSF_I(inode);
sbi = VBOXSF_SBI(dentry->d_sb);
if (!sf_i->force_restat) {
if (time_before(jiffies, dentry->d_time + sbi->o.ttl))
return 0;
Expand Down

0 comments on commit 94fed40

Please sign in to comment.