Skip to content

Commit

Permalink
cifs: check for private_data before trying to put it
Browse files Browse the repository at this point in the history
cifs_close doesn't check that the filp->private_data is non-NULL before
trying to put it. That can cause an oops in certain error conditions
that can occur on open or lookup before the private_data is set.

Reported-by: Ben Greear <greearb@candelatech.com>
CC: Stable <stable@kernel.org>
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Steve French <sfrench@us.ibm.com>
  • Loading branch information
Jeff Layton authored and Steve French committed Apr 12, 2011
1 parent a6360dd commit 7797069
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions fs/cifs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -575,8 +575,10 @@ static int cifs_reopen_file(struct cifsFileInfo *pCifsFile, bool can_flush)

int cifs_close(struct inode *inode, struct file *file)
{
cifsFileInfo_put(file->private_data);
file->private_data = NULL;
if (file->private_data != NULL) {
cifsFileInfo_put(file->private_data);
file->private_data = NULL;
}

/* return code from the ->release op is always ignored */
return 0;
Expand Down

0 comments on commit 7797069

Please sign in to comment.