diff options
author | Tyler Hicks <tyhicks@canonical.com> | 2013-11-13 13:09:42 -0500 |
---|---|---|
committer | Tyler Hicks <tyhicks@canonical.com> | 2013-11-14 15:12:15 -0500 |
commit | 2000f5beabc9c6baf084de5f7879975408e3652c (patch) | |
tree | 73840a7dd710710ef203cade2cfc31e873d28abb /fs/ecryptfs | |
parent | 42a2d923cc349583ebf6fdd52a7d35e1c2f7e6bd (diff) |
eCryptfs: file->private_data is always valid
When accessing the lower_file pointer located in private_data of
eCryptfs files, there is no need to check to see if the private_data
pointer has been initialized to a non-NULL value. The file->private_data
and file->private_data->lower_file pointers are always initialized to
non-NULL values in ecryptfs_open().
This change quiets a Smatch warning:
CHECK /var/scm/kernel/linux/fs/ecryptfs/file.c
fs/ecryptfs/file.c:321 ecryptfs_unlocked_ioctl() error: potential NULL dereference 'lower_file'.
fs/ecryptfs/file.c:335 ecryptfs_compat_ioctl() error: potential NULL dereference 'lower_file'.
Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Geyslan G. Bem <geyslan@gmail.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/ecryptfs')
-rw-r--r-- | fs/ecryptfs/file.c | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/fs/ecryptfs/file.c b/fs/ecryptfs/file.c index 2229a74aeeed..b1eaa7a1f82c 100644 --- a/fs/ecryptfs/file.c +++ b/fs/ecryptfs/file.c | |||
@@ -313,11 +313,9 @@ static int ecryptfs_fasync(int fd, struct file *file, int flag) | |||
313 | static long | 313 | static long |
314 | ecryptfs_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | 314 | ecryptfs_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg) |
315 | { | 315 | { |
316 | struct file *lower_file = NULL; | 316 | struct file *lower_file = ecryptfs_file_to_lower(file); |
317 | long rc = -ENOTTY; | 317 | long rc = -ENOTTY; |
318 | 318 | ||
319 | if (ecryptfs_file_to_private(file)) | ||
320 | lower_file = ecryptfs_file_to_lower(file); | ||
321 | if (lower_file->f_op->unlocked_ioctl) | 319 | if (lower_file->f_op->unlocked_ioctl) |
322 | rc = lower_file->f_op->unlocked_ioctl(lower_file, cmd, arg); | 320 | rc = lower_file->f_op->unlocked_ioctl(lower_file, cmd, arg); |
323 | return rc; | 321 | return rc; |
@@ -327,11 +325,9 @@ ecryptfs_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
327 | static long | 325 | static long |
328 | ecryptfs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | 326 | ecryptfs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) |
329 | { | 327 | { |
330 | struct file *lower_file = NULL; | 328 | struct file *lower_file = ecryptfs_file_to_lower(file); |
331 | long rc = -ENOIOCTLCMD; | 329 | long rc = -ENOIOCTLCMD; |
332 | 330 | ||
333 | if (ecryptfs_file_to_private(file)) | ||
334 | lower_file = ecryptfs_file_to_lower(file); | ||
335 | if (lower_file->f_op && lower_file->f_op->compat_ioctl) | 331 | if (lower_file->f_op && lower_file->f_op->compat_ioctl) |
336 | rc = lower_file->f_op->compat_ioctl(lower_file, cmd, arg); | 332 | rc = lower_file->f_op->compat_ioctl(lower_file, cmd, arg); |
337 | return rc; | 333 | return rc; |