[PATCH v2] mkfs.ubifs: Fix runtime assertions when running without crypto

Henri Roosen henriroosen at gmail.com
Mon Mar 8 14:57:10 GMT 2021


Running mkfs.ubifs which was build without crypto triggered the
following assertion:

mkfs.ubifs: ubifs-utils/mkfs.ubifs/fscrypt.h:166:
inherit_fscrypt_context: Assertion `0' failed.

A previous commit-cc4c5e295f54 ("mkfs.ubifs: Enable support for building
without crypto") added a check for an existing fscrypt context before calling
functions inherit_fscrypt_context() and free_fscrypt_context(),
however did not properly do this for each call to these functions.

Fixes: cc4c5e295f54 ("mkfs.ubifs: Enable support for building without crypto")
Signed-off-by: Henri Roosen <henri.roosen at ginzinger.com>
---
Changes since v1:
 - instead of patching every call site, allow inline functions
   inherit_fscrypt_context() and free_fscrypt_context() to be called with NULL
   fscrypt context.

 ubifs-utils/mkfs.ubifs/fscrypt.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ubifs-utils/mkfs.ubifs/fscrypt.h b/ubifs-utils/mkfs.ubifs/fscrypt.h
index 34b799c..ff3d326 100644
--- a/ubifs-utils/mkfs.ubifs/fscrypt.h
+++ b/ubifs-utils/mkfs.ubifs/fscrypt.h
@@ -131,7 +131,7 @@ static inline void free_fscrypt_context(struct fscrypt_context *fctx)
 {
 	(void)fctx;
 
-	assert(0);
+	assert(!fctx);
 }
 
 static inline int encrypt_path(void **outbuf, void *data, unsigned int data_len,
@@ -163,7 +163,7 @@ static inline struct fscrypt_context *inherit_fscrypt_context(struct fscrypt_con
 {
 	(void)fctx;
 
-	assert(0);
+	assert(!fctx);
 	return NULL;
 }
 #endif /* WITH_CRYPTO */
-- 
2.20.1




More information about the linux-mtd mailing list