Browse Source

ipc : gpr-lite: Add NULL check for gpr dev pointer

it is possible that gpr may get deregistered already and
hence will not get any pointer for gpr from dev_get_drvdata
so proceed further only if gpr exists otherwise,
it will lead to crash issue.

Change-Id: I4129a76d1deade0c243c9a9515a8f84542f3596c
Deepali Jindal 2 years ago
parent
commit
69fa44f6db
1 changed files with 6 additions and 0 deletions
  1. 6 0
      ipc/gpr-lite.c

+ 6 - 0
ipc/gpr-lite.c

@@ -110,6 +110,12 @@ int gpr_send_pkt(struct gpr_device *adev, struct gpr_pkt *pkt)
 
 	gpr = dev_get_drvdata(adev->dev.parent);
 
+	if (!gpr) {
+		pr_err_ratelimited("%s: Failed to get gpr dev pointer : gpr[%pK] \n",
+			__func__, gpr);
+		return -EINVAL;
+	}
+
 	if ((adev->domain_id == GPR_DOMAIN_ADSP) &&
 	    (gpr_get_q6_state() != GPR_SUBSYS_LOADED)) {
 		dev_err_ratelimited(gpr->dev, "%s: domain_id[%d], Still Dsp is not Up\n",