Skip to contentSkip to conversation

block: fix bmd->is_null_mapped initialization

PATCH Applied Christoph Hellwig 3 participants 3 messages Sep 23, 2020 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 block: fix bmd->is_null_mapped initialization

bmd is allocated using kmalloc in bio_alloc_map_data, so make sure is_null_mapped is properly initialized to false for the !null_mapped case.

Fixes f3256075ba49 ("block: remove the BIO_NULL_MAPPED flag")
---
 block/blk-map.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
block/blk-map.c +1 -2
index be118926ccf4e3..21630dccac628c 100644
@@ -148,6 +148,7 @@ static int bio_copy_user_iov(struct request *rq, struct rq_map_data *map_data,
 	 * shortlived one.
 	 */
 	bmd->is_our_pages = !map_data;
+	bmd->is_null_mapped = (map_data && map_data->null_mapped);
 
 	nr_pages = DIV_ROUND_UP(offset + len, PAGE_SIZE);
 	if (nr_pages > BIO_MAX_PAGES)
@@ -218,8 +219,6 @@ static int bio_copy_user_iov(struct request *rq, struct rq_map_data *map_data,
 	}
 
 	bio->bi_private = bmd;
-	if (map_data && map_data->null_mapped)
-		bmd->is_null_mapped = true;
 
 	bounce_bio = bio;
 	ret = blk_rq_append_bio(rq, &bounce_bio);
Signature · 1 line
2.28.0
maintainer Applied
#1 lore raw
Quoted 3 lines · Christoph Hellwig

bmd is allocated using kmalloc in bio_alloc_map_data, so make sure is_null_mapped is properly initialized to false for the !null_mapped case.

Applied, thanks.

Signature · 1 line
Jens Axboe
Tested-by on v1 1/1
#2 lore raw
In reply to Christoph Hellwig
Quoted 34 lines · Christoph Hellwig

bmd is allocated using kmalloc in bio_alloc_map_data, so make sure is_null_mapped is properly initialized to false for the !null_mapped case.

Fixes f3256075ba49 ("block: remove the BIO_NULL_MAPPED flag")
---
 block/blk-map.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
block/blk-map.c +1 -2
index be118926ccf4e3..21630dccac628c 100644
@@ -148,6 +148,7 @@ static int bio_copy_user_iov(struct request *rq, struct rq_map_data *map_data,
 	 * shortlived one.
 	 */
 	bmd->is_our_pages = !map_data;
+	bmd->is_null_mapped = (map_data && map_data->null_mapped);
 
 	nr_pages = DIV_ROUND_UP(offset + len, PAGE_SIZE);
 	if (nr_pages > BIO_MAX_PAGES)
@@ -218,8 +219,6 @@ static int bio_copy_user_iov(struct request *rq, struct rq_map_data *map_data,
 	}
 
 	bio->bi_private = bmd;
-	if (map_data && map_data->null_mapped)
-		bmd->is_null_mapped = true;
 
 	bounce_bio = bio;
 	ret = blk_rq_append_bio(rq, &bounce_bio);
Signature · 1 line
2.28.0