aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhangfei Gao <zhangfei.gao@linaro.org>2013-07-24 11:14:59 +0800
committerZhangfei Gao <zhangfei.gao@linaro.org>2013-07-24 11:14:59 +0800
commit7af0447f05111e1b1489e9dee45ff49aa5448a06 (patch)
treee7cfcb101a00d0af4303f82df9b6a1a279853c62
parent946b8936cfb62ab6495d03c89d6ee79be983acdc (diff)
staging: android: ashmem: ashmem_read & ashmem_llseek add check
In cts test, asma->file->f_op->read = NULL and asma->file->f_op->llseek = NULL will happen Signed-off-by: Zhangfei Gao <zhangfei.gao@linaro.org>
-rw-r--r--drivers/staging/android/ashmem.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c
index bb76f9ebd40b..7040cfe2981d 100644
--- a/drivers/staging/android/ashmem.c
+++ b/drivers/staging/android/ashmem.c
@@ -231,6 +231,18 @@ static ssize_t ashmem_read(struct file *file, char __user *buf,
goto out;
}
+ if (!asma->file->f_op) {
+ pr_info("asma->file->f_op is NULL\n");
+ ret = -EBADF;
+ goto out;
+ }
+
+ if (!asma->file->f_op->read) {
+ pr_info("asma->file->f_op->read is NULL\n");
+ ret = -EBADF;
+ goto out;
+ }
+
ret = asma->file->f_op->read(asma->file, buf, len, pos);
if (ret < 0)
goto out;
@@ -260,6 +272,18 @@ static loff_t ashmem_llseek(struct file *file, loff_t offset, int origin)
goto out;
}
+ if (!asma->file->f_op) {
+ pr_info("asma->file->f_op is NULL\n");
+ ret = -EBADF;
+ goto out;
+ }
+
+ if (!asma->file->f_op->llseek) {
+ pr_info("asma->file->f_op->llseek is NULL\n");
+ ret = -EBADF;
+ goto out;
+ }
+
ret = asma->file->f_op->llseek(asma->file, offset, origin);
if (ret < 0)
goto out;