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

Commit 6b6d1baa authored by Neeraj Soni's avatar Neeraj Soni Committed by Ramandeep Trehan
Browse files

scsi: ufs: ice: propagate memeory allocation failure error



It is possible that ice workqueue allocation fails in cases like
low memory or other workqueue allocation failures. Propagate proper
error code up in call stack for effective error handling by system. Also
check if ice workqueue is allocated before scheduling it to avoid possible
NULL pointer dereference.

Change-Id: I5aec3c20b31d6c3a78f7389b6df26fad2ebfb041
Signed-off-by: default avatarNeeraj Soni <neersoni@codeaurora.org>
parent fa8b293e
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
@@ -231,6 +231,7 @@ int ufs_qcom_ice_init(struct ufs_qcom_host *qcom_host)
	if (!ice_workqueue) {
		dev_err(ufs_dev, "%s: workqueue allocation failed.\n",
			__func__);
		err = -ENOMEM;
		goto out;
	}
	INIT_WORK(&qcom_host->ice_cfg_work, ufs_qcom_ice_cfg_work);
@@ -286,6 +287,20 @@ int ufs_qcom_ice_req_setup(struct ufs_qcom_host *qcom_host,
			 * propagate so it will be re-queued.
			 */
			if (err == -EAGAIN) {
				if (!ice_workqueue) {
					dev_err(qcom_host->hba->dev,
						"%s: error %d workqueue NULL\n",
						__func__, err);
					/*
					 * over write the error code to halt
					 * the request from upper layer as
					 * system is possibly in low memory
					 * state. Give system a chance to
					 * recover and reinitialize ice driver.
					 */
					return -EINVAL;
				}

				dev_dbg(qcom_host->hba->dev,
					"%s: scheduling task for ice setup\n",
					__func__);
@@ -405,6 +420,19 @@ int ufs_qcom_ice_cfg_start(struct ufs_qcom_host *qcom_host,
			 * propagate so it will be re-queued.
			 */
			if (err == -EAGAIN) {
				if (!ice_workqueue) {
					dev_err(qcom_host->hba->dev,
						"%s: error %d workqueue NULL\n",
						__func__, err);
					/*
					 * over write the error code to halt
					 * the request from upper layer as
					 * system is possibly in low memory
					 * state. Give system a chance to
					 * recover and reinitialize ice driver.
					 */
					return -EINVAL;
				}

				dev_dbg(qcom_host->hba->dev,
					"%s: scheduling task for ice setup\n",