Fix some static analyser issues
am: 300dae7c38
* commit '300dae7c38e6853148a998dfc1030b2be40490b5':
Fix some static analyser issues
diff --git a/cryptfs.c b/cryptfs.c
index 918a48a..a1f17a8 100644
--- a/cryptfs.c
+++ b/cryptfs.c
@@ -164,6 +164,11 @@
goto out;
}
+ if (!keymaster0_dev || !keymaster0_dev->common.module) {
+ rc = -1;
+ goto out;
+ }
+
// TODO(swillden): Check to see if there's any reason to require v0.3. I think v0.1 and v0.2
// should work.
if (keymaster0_dev->common.module->module_api_version
@@ -889,12 +894,10 @@
return -1;
}
- if (persist_data == NULL) {
- pdata = malloc(crypt_ftr.persist_data_size);
- if (pdata == NULL) {
- SLOGE("Cannot allocate memory for persistent data");
- goto err;
- }
+ pdata = malloc(crypt_ftr.persist_data_size);
+ if (pdata == NULL) {
+ SLOGE("Cannot allocate memory for persistent data");
+ goto err;
}
for (i = 0; i < 2; i++) {
@@ -3830,6 +3833,11 @@
rc = decrypt_master_key(password, master_key, ftr, &intermediate_key,
&intermediate_key_size);
+ if (rc) {
+ SLOGE("Can't calculate intermediate key");
+ return rc;
+ }
+
int N = 1 << ftr->N_factor;
int r = 1 << ftr->r_factor;
int p = 1 << ftr->p_factor;
@@ -3844,7 +3852,7 @@
free(intermediate_key);
if (rc) {
- SLOGE("Can't calculate intermediate key");
+ SLOGE("Can't scrypt intermediate key");
return rc;
}