From 554a879753a871ec432523e407bf4eb984bb3968 Mon Sep 17 00:00:00 2001 From: Ilia Lin Date: Mon, 13 Jul 2020 12:04:33 +0300 Subject: [PATCH] gsi: Fix NULL pointer dereference on event-less channels If gsi_start_channel() or gsi_stop_channel() are called on a channel with no event ring allocated, there will be null pointer dereference error. Adding null pointer check. Change-Id: I200aa09f49c2394041f66c33c458f7daa9aeaf8c Signed-off-by: Ilia Lin --- drivers/platform/msm/gsi/gsi.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/platform/msm/gsi/gsi.c b/drivers/platform/msm/gsi/gsi.c index 244f0cbc26b18..39aec377d04bd 100644 --- a/drivers/platform/msm/gsi/gsi.c +++ b/drivers/platform/msm/gsi/gsi.c @@ -2991,7 +2991,8 @@ int gsi_start_channel(unsigned long chan_hdl) /* check if INTSET is in IRQ mode for GPI channel */ val = gsi_readl(gsi_ctx->base + GSI_EE_n_CNTXT_INTSET_OFFS(gsi_ctx->per.ee)); - if (ctx->evtr->props.intf == GSI_EVT_CHTYPE_GPI_EV && + if (ctx->evtr && + ctx->evtr->props.intf == GSI_EVT_CHTYPE_GPI_EV && val != GSI_INTR_IRQ) { GSIERR("GSI_EE_n_CNTXT_INTSET_OFFS %d\n", val); BUG(); @@ -3074,7 +3075,8 @@ int gsi_stop_channel(unsigned long chan_hdl) /* check if INTSET is in IRQ mode for GPI channel */ val = gsi_readl(gsi_ctx->base + GSI_EE_n_CNTXT_INTSET_OFFS(gsi_ctx->per.ee)); - if (ctx->evtr->props.intf == GSI_EVT_CHTYPE_GPI_EV && + if (ctx->evtr && + ctx->evtr->props.intf == GSI_EVT_CHTYPE_GPI_EV && val != GSI_INTR_IRQ) { GSIERR("GSI_EE_n_CNTXT_INTSET_OFFS %d\n", val); BUG();