Commit 09fada5b authored by Al Viro's avatar Al Viro

slightly reduce lossage in gdm72xx

* filp_close() needs non-NULL second argument only if it'd been in descriptor
table
* opened files have non-NULL dentries, TYVM
* ... and those dentries are positive - it's kinda hard to open a file that
doesn't exist.
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 32aecdd3
...@@ -67,9 +67,8 @@ static int download_image(struct sdio_func *func, char *img_name) ...@@ -67,9 +67,8 @@ static int download_image(struct sdio_func *func, char *img_name)
return -ENOENT; return -ENOENT;
} }
if (filp->f_dentry) inode = filp->f_dentry->d_inode;
inode = filp->f_dentry->d_inode; if (!S_ISREG(inode->i_mode)) {
if (!inode || !S_ISREG(inode->i_mode)) {
printk(KERN_ERR "Invalid file type: %s\n", img_name); printk(KERN_ERR "Invalid file type: %s\n", img_name);
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
...@@ -124,7 +123,7 @@ static int download_image(struct sdio_func *func, char *img_name) ...@@ -124,7 +123,7 @@ static int download_image(struct sdio_func *func, char *img_name)
pno++; pno++;
} }
out: out:
filp_close(filp, current->files); filp_close(filp, NULL);
return ret; return ret;
} }
......
...@@ -174,14 +174,12 @@ int usb_boot(struct usb_device *usbdev, u16 pid) ...@@ -174,14 +174,12 @@ int usb_boot(struct usb_device *usbdev, u16 pid)
filp = filp_open(img_name, O_RDONLY | O_LARGEFILE, 0); filp = filp_open(img_name, O_RDONLY | O_LARGEFILE, 0);
if (IS_ERR(filp)) { if (IS_ERR(filp)) {
printk(KERN_ERR "Can't find %s.\n", img_name); printk(KERN_ERR "Can't find %s.\n", img_name);
set_fs(fs);
ret = -ENOENT; ret = -ENOENT;
goto restore_fs; goto restore_fs;
} }
if (filp->f_dentry) inode = filp->f_dentry->d_inode;
inode = filp->f_dentry->d_inode; if (!S_ISREG(inode->i_mode)) {
if (!inode || !S_ISREG(inode->i_mode)) {
printk(KERN_ERR "Invalid file type: %s\n", img_name); printk(KERN_ERR "Invalid file type: %s\n", img_name);
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
...@@ -263,7 +261,7 @@ int usb_boot(struct usb_device *usbdev, u16 pid) ...@@ -263,7 +261,7 @@ int usb_boot(struct usb_device *usbdev, u16 pid)
ret = -EINVAL; ret = -EINVAL;
} }
out: out:
filp_close(filp, current->files); filp_close(filp, NULL);
restore_fs: restore_fs:
set_fs(fs); set_fs(fs);
...@@ -323,13 +321,11 @@ static int em_download_image(struct usb_device *usbdev, char *path, ...@@ -323,13 +321,11 @@ static int em_download_image(struct usb_device *usbdev, char *path,
goto restore_fs; goto restore_fs;
} }
if (filp->f_dentry) { inode = filp->f_dentry->d_inode;
inode = filp->f_dentry->d_inode; if (!S_ISREG(inode->i_mode)) {
if (!inode || !S_ISREG(inode->i_mode)) { printk(KERN_ERR "Invalid file type: %s\n", path);
printk(KERN_ERR "Invalid file type: %s\n", path); ret = -EINVAL;
ret = -EINVAL; goto out;
goto out;
}
} }
buf = kmalloc(DOWNLOAD_CHUCK + pad_size, GFP_KERNEL); buf = kmalloc(DOWNLOAD_CHUCK + pad_size, GFP_KERNEL);
...@@ -365,7 +361,7 @@ static int em_download_image(struct usb_device *usbdev, char *path, ...@@ -365,7 +361,7 @@ static int em_download_image(struct usb_device *usbdev, char *path,
goto out; goto out;
out: out:
filp_close(filp, current->files); filp_close(filp, NULL);
restore_fs: restore_fs:
set_fs(fs); set_fs(fs);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment