Message ID | 8758569c543389604d8a6a9460de086246fabe89.1680108414.git.johannes.thumshirn@wdc.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | bio: check return values of bio_add_page | expand |
On 3/30/23 02:06, Johannes Thumshirn wrote: > The sync request code uses bio_add_page() to add a page to a newly created bio. > bio_add_page() can fail, but the return value is never checked. > > Use __bio_add_page() as adding a single page to a newly created bio is > guaranteed to succeed. > > This brings us a step closer to marking bio_add_page() as __must_check. > > 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 bd7c339a84a1..c226d293992f 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -2915,7 +2915,7 @@ static sector_t raid1_sync_request(struct mddev *mddev, sector_t sector_nr, * won't fail because the vec table is big * enough to hold all these pages */ - bio_add_page(bio, page, len, 0); + __bio_add_page(bio, page, len, 0); } } nr_sectors += len>>9;
The sync request code uses bio_add_page() to add a page to a newly created bio. bio_add_page() can fail, but the return value is never checked. Use __bio_add_page() as adding a single page to a newly created bio is guaranteed to succeed. This brings us a step closer to marking bio_add_page() as __must_check. Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> --- drivers/md/raid1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)