powerpc/vas: Fix potential NULL pointer dereference
authorGustavo A. R. Silva <gustavoars@kernel.org>
Fri, 15 Oct 2021 05:03:45 +0000 (00:03 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 18 Nov 2021 18:17:19 +0000 (19:17 +0100)
commit0356cc5d27c239892809dcb97464850d6badbad8
tree3373a93a4aca06a8c7b8c1d498c4042630b4a6de
parentb75b27e4e6405a5c96ba4ea93c349168a56a0e99
powerpc/vas: Fix potential NULL pointer dereference

commit 61cb9ac66b30374c7fd8a8b2a3c4f8f432c72e36 upstream.

(!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
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/powerpc/platforms/book3s/vas-api.c