Skip to contentSkip to conversation

fscrypt: inline fscrypt_free_filename()

PATCH Applied Eric Biggers 3 participants 3 messages May 23, 2017 – Jun 24, 2017 fscrypt: file system level encryption support

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fscrypt: inline fscrypt_free_filename()

From: Eric Biggers <[email protected]>

fscrypt_free_filename() only needs to do a kfree() of crypto_buf.name, which works well as an inline function. We can skip setting the various pointers to NULL, since no user cares about it (the name is always freed just before it goes out of scope).

---
 fs/crypto/fname.c            | 9 ---------
 include/linux/fscrypt_supp.h | 7 ++++++-
 2 files changed, 6 insertions(+), 10 deletions(-)
fs/crypto/fname.c +0 -9
index d1bb02b1ee58..ad9f814fdead 100644
@@ -453,12 +453,3 @@ int fscrypt_setup_filename(struct inode *dir, const struct qstr *iname,
 	return ret;
 }
 EXPORT_SYMBOL(fscrypt_setup_filename);
-
-void fscrypt_free_filename(struct fscrypt_name *fname)
-{
-	kfree(fname->crypto_buf.name);
-	fname->crypto_buf.name = NULL;
-	fname->usr_fname = NULL;
-	fname->disk_name.name = NULL;
-}
-EXPORT_SYMBOL(fscrypt_free_filename);
include/linux/fscrypt_supp.h +6 -1
index cd4e82c17304..32e2fcf13b01 100644
@@ -47,7 +47,12 @@ extern void fscrypt_put_encryption_info(struct inode *, struct fscrypt_info *);
 /* fname.c */
 extern int fscrypt_setup_filename(struct inode *, const struct qstr *,
 				int lookup, struct fscrypt_name *);
-extern void fscrypt_free_filename(struct fscrypt_name *);
+
+static inline void fscrypt_free_filename(struct fscrypt_name *fname)
+{
+	kfree(fname->crypto_buf.name);
+}
+
 extern u32 fscrypt_fname_encrypted_size(const struct inode *, u32);
 extern int fscrypt_fname_alloc_buffer(const struct inode *, u32,
 				struct fscrypt_str *);
Signature · 1 line
2.13.0.219.gdb65acc882-goog
Reviewed-by on v1 1/1
#1 lore raw

Hi Eric,

Quoted 52 lines · Eric Biggers

From: Eric Biggers <[email protected]>

fscrypt_free_filename() only needs to do a kfree() of crypto_buf.name, which works well as an inline function. We can skip setting the various pointers to NULL, since no user cares about it (the name is always freed just before it goes out of scope).

---
fs/crypto/fname.c | 9 ---------
include/linux/fscrypt_supp.h | 7 ++++++-

2 files changed, 6 insertions(+), 10 deletions(-)
fs/crypto/fname.c +0 -9
index d1bb02b1ee58..ad9f814fdead 100644
@@ -453,12 +453,3 @@ int fscrypt_setup_filename(struct inode *dir, const struct qstr *iname,
 	return ret;
 }
 EXPORT_SYMBOL(fscrypt_setup_filename);
-
-void fscrypt_free_filename(struct fscrypt_name *fname)
-{
-	kfree(fname->crypto_buf.name);
-	fname->crypto_buf.name = NULL;
-	fname->usr_fname = NULL;
-	fname->disk_name.name = NULL;
-}
-EXPORT_SYMBOL(fscrypt_free_filename);
include/linux/fscrypt_supp.h +6 -1
index cd4e82c17304..32e2fcf13b01 100644
@@ -47,7 +47,12 @@ extern void fscrypt_put_encryption_info(struct inode *, struct fscrypt_info *);
 /* fname.c */
 extern int fscrypt_setup_filename(struct inode *, const struct qstr *,
 				int lookup, struct fscrypt_name *);
-extern void fscrypt_free_filename(struct fscrypt_name *);
+
+static inline void fscrypt_free_filename(struct fscrypt_name *fname)
+{
+	kfree(fname->crypto_buf.name);
+}
+
 extern u32 fscrypt_fname_encrypted_size(const struct inode *, u32);
 extern int fscrypt_fname_alloc_buffer(const struct inode *, u32,
 				struct fscrypt_str *);
Signature · 1 line
2.13.0.219.gdb65acc882-goog

LGTM.

David