Răsfoiți Sursa

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 <[email protected]>
Ilia Lin 4 ani în urmă
părinte
comite
554a879753
1 a modificat fișierele cu 4 adăugiri și 2 ștergeri
  1. 4 2
      drivers/platform/msm/gsi/gsi.c

+ 4 - 2
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 */
 	/* check if INTSET is in IRQ mode for GPI channel */
 	val = gsi_readl(gsi_ctx->base +
 	val = gsi_readl(gsi_ctx->base +
 			GSI_EE_n_CNTXT_INTSET_OFFS(gsi_ctx->per.ee));
 			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) {
 		val != GSI_INTR_IRQ) {
 		GSIERR("GSI_EE_n_CNTXT_INTSET_OFFS %d\n", val);
 		GSIERR("GSI_EE_n_CNTXT_INTSET_OFFS %d\n", val);
 		BUG();
 		BUG();
@@ -3074,7 +3075,8 @@ int gsi_stop_channel(unsigned long chan_hdl)
 	/* check if INTSET is in IRQ mode for GPI channel */
 	/* check if INTSET is in IRQ mode for GPI channel */
 	val = gsi_readl(gsi_ctx->base +
 	val = gsi_readl(gsi_ctx->base +
 			GSI_EE_n_CNTXT_INTSET_OFFS(gsi_ctx->per.ee));
 			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) {
 		val != GSI_INTR_IRQ) {
 		GSIERR("GSI_EE_n_CNTXT_INTSET_OFFS %d\n", val);
 		GSIERR("GSI_EE_n_CNTXT_INTSET_OFFS %d\n", val);
 		BUG();
 		BUG();