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

Commit e617689a authored by Michael Adisumarta's avatar Michael Adisumarta Committed by Gerrit - the friendly Code Review server
Browse files

msm: gsi: gsi_ctx pointer dereference fix



Check if gsi_ctx pointer is null before dereferencing it.

Change-Id: Icbdd100c00e4d04183af55ef41570414afbdb6c2
CRs-Fixed: 2102065
Signed-off-by: default avatarMichael Adisumarta <madisuma@codeaurora.org>
parent ea7861da
Loading
Loading
Loading
Loading
+10 −5
Original line number Diff line number Diff line
@@ -1099,13 +1099,14 @@ int gsi_alloc_evt_ring(struct gsi_evt_ring_props *props, unsigned long dev_hdl,
	uint32_t val;
	struct gsi_evt_ctx *ctx;
	int res;
	int ee = gsi_ctx->per.ee;
	int ee;
	unsigned long flags;

	if (!gsi_ctx) {
		pr_err("%s:%d gsi context not allocated\n", __func__, __LINE__);
		return -GSI_STATUS_NODEV;
	}
	ee = gsi_ctx->per.ee;

	if (!props || !evt_ring_hdl || dev_hdl != (uintptr_t)gsi_ctx) {
		GSIERR("bad params props=%p dev_hdl=0x%lx evt_ring_hdl=%p\n",
@@ -1637,7 +1638,7 @@ int gsi_alloc_channel(struct gsi_chan_props *props, unsigned long dev_hdl,
	struct gsi_chan_ctx *ctx;
	uint32_t val;
	int res;
	int ee = gsi_ctx->per.ee;
	int ee;
	enum gsi_ch_cmd_opcode op = GSI_CH_ALLOCATE;
	uint8_t erindex;
	void **user_data;
@@ -1646,6 +1647,7 @@ int gsi_alloc_channel(struct gsi_chan_props *props, unsigned long dev_hdl,
		pr_err("%s:%d gsi context not allocated\n", __func__, __LINE__);
		return -GSI_STATUS_NODEV;
	}
	ee = gsi_ctx->per.ee;

	if (!props || !chan_hdl || dev_hdl != (uintptr_t)gsi_ctx) {
		GSIERR("bad params props=%p dev_hdl=0x%lx chan_hdl=%p\n",
@@ -2287,12 +2289,13 @@ int gsi_query_channel_info(unsigned long chan_hdl,
	unsigned long flags;
	uint64_t rp;
	uint64_t wp;
	int ee = gsi_ctx->per.ee;
	int ee;

	if (!gsi_ctx) {
		pr_err("%s:%d gsi context not allocated\n", __func__, __LINE__);
		return -GSI_STATUS_NODEV;
	}
	ee = gsi_ctx->per.ee;

	if (chan_hdl >= gsi_ctx->max_ch || !info) {
		GSIERR("bad params chan_hdl=%lu info=%p\n", chan_hdl, info);
@@ -2357,12 +2360,13 @@ int gsi_is_channel_empty(unsigned long chan_hdl, bool *is_empty)
	unsigned long flags;
	uint64_t rp;
	uint64_t wp;
	int ee = gsi_ctx->per.ee;
	int ee;

	if (!gsi_ctx) {
		pr_err("%s:%d gsi context not allocated\n", __func__, __LINE__);
		return -GSI_STATUS_NODEV;
	}
	ee = gsi_ctx->per.ee;

	if (chan_hdl >= gsi_ctx->max_ch || !is_empty) {
		GSIERR("bad params chan_hdl=%lu is_empty=%p\n",
@@ -2546,13 +2550,14 @@ int gsi_poll_channel(unsigned long chan_hdl,
{
	struct gsi_chan_ctx *ctx;
	uint64_t rp;
	int ee = gsi_ctx->per.ee;
	int ee;
	unsigned long flags;

	if (!gsi_ctx) {
		pr_err("%s:%d gsi context not allocated\n", __func__, __LINE__);
		return -GSI_STATUS_NODEV;
	}
	ee = gsi_ctx->per.ee;

	if (chan_hdl >= gsi_ctx->max_ch || !notify) {
		GSIERR("bad params chan_hdl=%lu notify=%p\n", chan_hdl, notify);