ipc: wcd-dsp-glink: prevent potential NULL pointer dereference
The current logic that checks pointer "rpdev" for NULL is not
correct. Fix it to prevent potential NULL pointer dereference.
Change-Id: Ieaad98396ff43b66b0dd41efbfbf9f6ae923a2bb
Signed-off-by: Xiaoyu Ye <benyxy@codeaurora.org>
diff --git a/ipc/wcd-dsp-glink.c b/ipc/wcd-dsp-glink.c
index 8e1d8a2..21da65a 100644
--- a/ipc/wcd-dsp-glink.c
+++ b/ipc/wcd-dsp-glink.c
@@ -266,7 +266,7 @@
spin_lock(&ch->ch_lock);
rpdev = ch->handle;
- if (rpdev || ch->ch_state == WDSP_CH_CONNECTED) {
+ if (rpdev && ch->ch_state == WDSP_CH_CONNECTED) {
spin_unlock(&ch->ch_lock);
ret = rpmsg_send(rpdev->ept, cpkt->payload,
cpkt->payload_size);
@@ -275,8 +275,11 @@
__func__, ret);
} else {
spin_unlock(&ch->ch_lock);
- dev_err(wpriv->dev, "%s: channel %s is not in connected state\n",
- __func__, ch->ch_name);
+ if (rpdev)
+ dev_err(wpriv->dev, "%s: channel %s is not in connected state\n",
+ __func__, ch->ch_name);
+ else
+ dev_err(wpriv->dev, "%s: rpdev is NULL\n", __func__);
}
vfree(tx_buf);
}