Skip to contentSkip to conversation

misc: rtsx: check the value returned from a function for errors before being used

PATCH In review Yang Li 2 participants 2 messages Mar 24, 2021 Char and misc drivers

lore
Share & tools
lore

Yang Li

author
#0 lore raw

PATCH 1/1 misc: rtsx: check the value returned from a function for errors before being used

Add missing return value check in pm_runtime_get disabling the sensor. The issue is reported by coverity with the following error:

Medium:Unchecked return value(CHECKED_RETURN)
CWE252: Value returned from a function is not checked for errors before being used.
Calling "pm_runtime_get" without checking return value.

---
 drivers/misc/cardreader/rtsx_pcr.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/misc/cardreader/rtsx_pcr.c +4 -1
index 2733111..2cc37fd 100644
@@ -142,13 +142,16 @@ static void rtsx_pm_full_on(struct rtsx_pcr *pcr)
 
 void rtsx_pci_start_run(struct rtsx_pcr *pcr)
 {
+	int status;
 	/* If pci device removed, don't queue idle work any more */
 	if (pcr->remove_pci)
 		return;
 
 	if (pcr->rtd3_en)
 		if (pcr->is_runtime_suspended) {
-			pm_runtime_get(&(pcr->pci->dev));
+			status = pm_runtime_get(&(pcr->pci->dev));
+			if (status < 0 && status != -EINPROGRESS)
+				pm_runtime_put_noidle(&(pcr->pci->dev));
 			pcr->is_runtime_suspended = false;
 		}
 
Signature · 1 line
1.8.3.1
maintainer
#1 lore raw
Quoted 39 lines · Yang Li

Add missing return value check in pm_runtime_get disabling the sensor. The issue is reported by coverity with the following error:

Medium:Unchecked return value(CHECKED_RETURN)
CWE252: Value returned from a function is not checked for errors before being used.
Calling "pm_runtime_get" without checking return value.

---
 drivers/misc/cardreader/rtsx_pcr.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/misc/cardreader/rtsx_pcr.c +4 -1
index 2733111..2cc37fd 100644
@@ -142,13 +142,16 @@ static void rtsx_pm_full_on(struct rtsx_pcr *pcr)
 
 void rtsx_pci_start_run(struct rtsx_pcr *pcr)
 {
+	int status;
 	/* If pci device removed, don't queue idle work any more */
 	if (pcr->remove_pci)
 		return;
 
 	if (pcr->rtd3_en)
 		if (pcr->is_runtime_suspended) {
-			pm_runtime_get(&(pcr->pci->dev));
+			status = pm_runtime_get(&(pcr->pci->dev));
+			if (status < 0 && status != -EINPROGRESS)
+				pm_runtime_put_noidle(&(pcr->pci->dev));
 			pcr->is_runtime_suspended = false;
 		}
 
Signature · 1 line
1.8.3.1

Please always run scripts/checkpatch.pl on your patch before submitting it.

thanks,

greg k-h