summaryrefslogtreecommitdiff
path: root/arch/powerpc/platforms/book3s
diff options
context:
space:
mode:
authorGustavo A. R. Silva <gustavoars@kernel.org>2021-10-15 08:03:45 +0300
committerMichael Ellerman <mpe@ellerman.id.au>2021-10-22 07:22:04 +0300
commit61cb9ac66b30374c7fd8a8b2a3c4f8f432c72e36 (patch)
tree387e0edd1c52d89addbcf8bb580b476e3b4f1793 /arch/powerpc/platforms/book3s
parent49e3d8ea62482625c3835f0a33ae9c1dda39ea8f (diff)
downloadlinux-61cb9ac66b30374c7fd8a8b2a3c4f8f432c72e36.tar.xz
powerpc/vas: Fix potential NULL pointer dereference
(!ptr && !ptr->foo) strikes again. :) The expression (!ptr && !ptr->foo) is bogus and in case ptr is NULL, it leads to a NULL pointer dereference: ptr->foo. Fix this by converting && to || This issue was detected with the help of Coccinelle, and audited and fixed manually. Fixes: 1a0d0d5ed5e3 ("powerpc/vas: Add platform specific user window operations") Cc: stable@vger.kernel.org Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org> Reviewed-by: Tyrel Datwyler <tyreld@linux.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/20211015050345.GA1161918@embeddedor
Diffstat (limited to 'arch/powerpc/platforms/book3s')
-rw-r--r--arch/powerpc/platforms/book3s/vas-api.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/arch/powerpc/platforms/book3s/vas-api.c b/arch/powerpc/platforms/book3s/vas-api.c
index 30172e52e16b..4d82c92ddd52 100644
--- a/arch/powerpc/platforms/book3s/vas-api.c
+++ b/arch/powerpc/platforms/book3s/vas-api.c
@@ -303,7 +303,7 @@ static int coproc_ioc_tx_win_open(struct file *fp, unsigned long arg)
return -EINVAL;
}
- if (!cp_inst->coproc->vops && !cp_inst->coproc->vops->open_win) {
+ if (!cp_inst->coproc->vops || !cp_inst->coproc->vops->open_win) {
pr_err("VAS API is not registered\n");
return -EACCES;
}
@@ -373,7 +373,7 @@ static int coproc_mmap(struct file *fp, struct vm_area_struct *vma)
return -EINVAL;
}
- if (!cp_inst->coproc->vops && !cp_inst->coproc->vops->paste_addr) {
+ if (!cp_inst->coproc->vops || !cp_inst->coproc->vops->paste_addr) {
pr_err("%s(): VAS API is not registered\n", __func__);
return -EACCES;
}