diff options
author | Andrey Markovytch <andreym@codeaurora.org> | 2015-12-02 15:47:14 +0200 |
---|---|---|
committer | Kyle Yan <kyan@codeaurora.org> | 2016-06-21 15:15:47 -0700 |
commit | 14bc610d32a8fd8ebb1f87c147df9614ca4e57da (patch) | |
tree | a6584b1c297795682fc92909921e1af19b6ca995 /security/pfe/pfk.c | |
parent | 2c477301dfd7c708f5e180e3485d901a3ba8b55a (diff) |
pfk: fixed crash that occurred because of bio's without data
bio's without data are not relevant, bio_had_data checks this,
replaced redundant checks to call to this function.
Also, additional clean ups performed
Change-Id: I315bcf43cf3d32e78d53b818571da1f5175f8ac3
Signed-off-by: Andrey Markovytch <andreym@codeaurora.org>
Diffstat (limited to 'security/pfe/pfk.c')
-rw-r--r-- | security/pfe/pfk.c | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/security/pfe/pfk.c b/security/pfe/pfk.c index 0ed4106d8f4b..ccaed3b23fec 100644 --- a/security/pfe/pfk.c +++ b/security/pfe/pfk.c @@ -166,9 +166,9 @@ static int pfk_get_page_index(const struct bio *bio, pgoff_t *page_index) if (!bio || !page_index) return -EINVAL; - /* check bio bi_size > 0 before using the bio->bi_io_vec[] array */ - if (!(bio->bi_iter).bi_size) + if (!bio_has_data((struct bio *)bio)) return -EINVAL; + if (!bio->bi_io_vec) return -EINVAL; if (!bio->bi_io_vec->bv_page) @@ -196,9 +196,10 @@ static struct inode *pfk_bio_get_inode(const struct bio *bio) { if (!bio) return NULL; - /* check bio bi_size > 0 before using the bio->bi_io_vec[] array */ - if (!(bio->bi_iter).bi_size) + + if (!bio_has_data((struct bio *)bio)) return NULL; + if (!bio->bi_io_vec) return NULL; if (!bio->bi_io_vec->bv_page) @@ -609,17 +610,13 @@ bool pfk_allow_merge_bio(struct bio *bio1, struct bio *bio2) void *ecryptfs_data2 = NULL; pgoff_t offset1, offset2; bool res = false; - struct inode *inode1 = NULL; - struct inode *inode2 = NULL; + /* if there is no pfk, don't disallow merging blocks */ if (!pfk_is_ready()) - return -ENODEV; + return true; if (!bio1 || !bio2) - return -EPERM; - - inode1 = pfk_bio_get_inode(bio1); - inode2 = pfk_bio_get_inode(bio2); + return false; ecryptfs_data1 = pfk_get_ecryptfs_data(pfk_bio_get_inode(bio1)); ecryptfs_data2 = pfk_get_ecryptfs_data(pfk_bio_get_inode(bio2)); |