Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a35aeb9a authored by Skylar Chang's avatar Skylar Chang
Browse files

msm: gsi: fix event ring handle in gsi_alloc_channel



Add a check to event ring handle.

Change-Id: If835e7e610745aeb82d4d0e363ef833d0f8d857a
CRs-Fixed: 1115476
Acked-by: default avatarAdy Abraham <adya@qti.qualcomm.com>
Signed-off-by: default avatarSkylar Chang <chiaweic@codeaurora.org>
parent 96337de3
Loading
Loading
Loading
Loading
+12 −6
Original line number Original line Diff line number Diff line
@@ -1591,14 +1591,20 @@ int gsi_alloc_channel(struct gsi_chan_props *props, unsigned long dev_hdl,
		return -GSI_STATUS_INVALID_PARAMS;
		return -GSI_STATUS_INVALID_PARAMS;
	}
	}


	if (props->evt_ring_hdl != ~0 &&
	if (props->evt_ring_hdl != ~0) {
		atomic_read(&gsi_ctx->evtr[props->evt_ring_hdl].chan_ref_cnt) &&
		if (props->evt_ring_hdl >= GSI_EVT_RING_MAX) {
			GSIERR("invalid evt ring=%lu\n", props->evt_ring_hdl);
			return -GSI_STATUS_INVALID_PARAMS;
		}

		if (atomic_read(
			&gsi_ctx->evtr[props->evt_ring_hdl].chan_ref_cnt) &&
			gsi_ctx->evtr[props->evt_ring_hdl].props.exclusive) {
			gsi_ctx->evtr[props->evt_ring_hdl].props.exclusive) {
		GSIERR("evt ring=%lu already in exclusive use chan_hdl=%p\n",
			GSIERR("evt ring=%lu exclusively used by chan_hdl=%p\n",
				props->evt_ring_hdl, chan_hdl);
				props->evt_ring_hdl, chan_hdl);
			return -GSI_STATUS_UNSUPPORTED_OP;
			return -GSI_STATUS_UNSUPPORTED_OP;
		}
		}

	}


	ctx = &gsi_ctx->chan[props->ch_id];
	ctx = &gsi_ctx->chan[props->ch_id];
	if (ctx->allocated) {
	if (ctx->allocated) {