Message ID | 76f5748e386870c034b46e919101a878b87a79bf.1680108414.git.johannes.thumshirn@wdc.com (mailing list archive) |
---|---|
State | Mainlined, archived |
Headers | show |
Series | bio: check return values of bio_add_page | expand |
On 3/30/23 02:06, Johannes Thumshirn wrote: > alloc_behind_master_bio() can possibly add multiple pages to a bio, but it > is not checking for the return value of bio_add_page() if adding really > succeeded. > > Check if the page adding succeeded and if not bail out. > > Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 68a9e2d9985b..bd7c339a84a1 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -1147,7 +1147,8 @@ static void alloc_behind_master_bio(struct r1bio *r1_bio, if (unlikely(!page)) goto free_pages; - bio_add_page(behind_bio, page, len, 0); + if (!bio_add_page(behind_bio, page, len, 0)) + goto free_pages; size -= len; i++;
alloc_behind_master_bio() can possibly add multiple pages to a bio, but it is not checking for the return value of bio_add_page() if adding really succeeded. Check if the page adding succeeded and if not bail out. Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> --- drivers/md/raid1.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)