cifs: check for private_data before trying to put it

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>
This commit is contained in:
Jeff Layton 2011-04-05 16:23:47 -07:00 committed by Steve French
parent a6360dd37e
commit 7797069305
1 changed files with 4 additions and 2 deletions

View File

@ -575,8 +575,10 @@ reopen_error_exit:
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;