Skip to content

Commit b67253b

Browse files
committed
powerpc/vas: Fix potential NULL pointer dereference
jira LE-1907 Rebuild_History Non-Buildable kernel-rt-5.14.0-284.30.1.rt14.315.el9_2 commit-author Gustavo A. R. Silva <gustavoars@kernel.org> commit 61cb9ac (!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: 1a0d0d5 ("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 (cherry picked from commit 61cb9ac) Signed-off-by: Jonathan Maple <jmaple@ciq.com>
1 parent 13e9667 commit b67253b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

arch/powerpc/platforms/book3s/vas-api.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ static int coproc_ioc_tx_win_open(struct file *fp, unsigned long arg)
303303
return -EINVAL;
304304
}
305305

306-
if (!cp_inst->coproc->vops && !cp_inst->coproc->vops->open_win) {
306+
if (!cp_inst->coproc->vops || !cp_inst->coproc->vops->open_win) {
307307
pr_err("VAS API is not registered\n");
308308
return -EACCES;
309309
}
@@ -492,7 +492,7 @@ static int coproc_mmap(struct file *fp, struct vm_area_struct *vma)
492492
return -EINVAL;
493493
}
494494

495-
if (!cp_inst->coproc->vops && !cp_inst->coproc->vops->paste_addr) {
495+
if (!cp_inst->coproc->vops || !cp_inst->coproc->vops->paste_addr) {
496496
pr_err("%s(): VAS API is not registered\n", __func__);
497497
return -EACCES;
498498
}

0 commit comments

Comments
 (0)