Skip to content

Commit d1f04c2

Browse files
ychoijyaxboe
authored andcommitted
bio-integrity: cleanup adding integrity pages to bip's bvec.
bio_integrity_add_page() returns the add length if successful, else 0, just as bio_add_page. Simply check return value checking in bio_integrity_prep to not deal with a > 0 but < len case that can't happen. Cc: Christoph Hellwig <hch@lst.de> Cc: Martin K. Petersen <martin.petersen@oracle.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jinyoung Choi <j-young.choi@samsung.com> Tested-by: "Martin K. Petersen" <martin.petersen@oracle.com> Reviewed-by: "Martin K. Petersen" <martin.petersen@oracle.com> Link: https://lore.kernel.org/r/20230803025058epcms2p5a4d0db5da2ad967668932d463661c633@epcms2p5 Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 80814b8 commit d1f04c2

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

block/bio-integrity.c

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -252,27 +252,18 @@ bool bio_integrity_prep(struct bio *bio)
252252

253253
/* Map it */
254254
offset = offset_in_page(buf);
255-
for (i = 0 ; i < nr_pages ; i++) {
256-
int ret;
255+
for (i = 0; i < nr_pages && len > 0; i++) {
257256
bytes = PAGE_SIZE - offset;
258257

259-
if (len <= 0)
260-
break;
261-
262258
if (bytes > len)
263259
bytes = len;
264260

265-
ret = bio_integrity_add_page(bio, virt_to_page(buf),
266-
bytes, offset);
267-
268-
if (ret == 0) {
261+
if (bio_integrity_add_page(bio, virt_to_page(buf),
262+
bytes, offset) < bytes) {
269263
printk(KERN_ERR "could not attach integrity payload\n");
270264
goto err_end_io;
271265
}
272266

273-
if (ret < bytes)
274-
break;
275-
276267
buf += bytes;
277268
len -= bytes;
278269
offset = 0;
@@ -291,7 +282,6 @@ bool bio_integrity_prep(struct bio *bio)
291282
bio->bi_status = BLK_STS_RESOURCE;
292283
bio_endio(bio);
293284
return false;
294-
295285
}
296286
EXPORT_SYMBOL(bio_integrity_prep);
297287

0 commit comments

Comments
 (0)