Browse code

Fix a possible deadlock bug due to unreleased lock

In acquire_spi, making condition of acquiring the releasing lock aligned.

ryancaicse authored on 19/11/2021 03:32:37 • GitHub committed on 19/11/2021 03:32:37
Showing 1 changed files
... ...
@@ -106,9 +106,9 @@ uint32_t acquire_spi()
106 106
 			spi_data->spi_val = spi_data->min_spi;
107 107
         }
108 108
 
109
-		if(spi_data->spi_val == initial_val){ //there are no free SPIs
110
-			pthread_mutex_unlock(&spi_data->spis_mut);
111
-            return ret;
109
+
110
+		pthread_mutex_unlock(&spi_data->spis_mut);
111
+		return ret;
112 112
         }
113 113
 
114 114
     }