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>
This commit is contained in:
parent
2c477301df
commit
14bc610d32
1 changed files with 8 additions and 11 deletions
|
@ -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));
|
||||
|
|
Loading…
Add table
Reference in a new issue