mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-01 10:42:11 +00:00
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>
This commit is contained in:
parent
42a2d923cc
commit
2000f5beab
@ -313,11 +313,9 @@ static int ecryptfs_fasync(int fd, struct file *file, int flag)
|
||||
static long
|
||||
ecryptfs_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
|
||||
{
|
||||
struct file *lower_file = NULL;
|
||||
struct file *lower_file = ecryptfs_file_to_lower(file);
|
||||
long rc = -ENOTTY;
|
||||
|
||||
if (ecryptfs_file_to_private(file))
|
||||
lower_file = ecryptfs_file_to_lower(file);
|
||||
if (lower_file->f_op->unlocked_ioctl)
|
||||
rc = lower_file->f_op->unlocked_ioctl(lower_file, cmd, arg);
|
||||
return rc;
|
||||
@ -327,11 +325,9 @@ ecryptfs_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
|
||||
static long
|
||||
ecryptfs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
|
||||
{
|
||||
struct file *lower_file = NULL;
|
||||
struct file *lower_file = ecryptfs_file_to_lower(file);
|
||||
long rc = -ENOIOCTLCMD;
|
||||
|
||||
if (ecryptfs_file_to_private(file))
|
||||
lower_file = ecryptfs_file_to_lower(file);
|
||||
if (lower_file->f_op && lower_file->f_op->compat_ioctl)
|
||||
rc = lower_file->f_op->compat_ioctl(lower_file, cmd, arg);
|
||||
return rc;
|
||||
|
Loading…
Reference in New Issue
Block a user