This is a note to let you know that I've just added the patch titled brd: return 0/-error from brd_insert_page() to the 6.1-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: brd-return-0-error-from-brd_insert_page.patch and it can be found in the queue-6.1 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From db0ccc44a20b4bb3039c0f6885a1f9c3323c7673 Mon Sep 17 00:00:00 2001 From: Jens Axboe <axboe@xxxxxxxxx> Date: Thu, 16 Feb 2023 07:57:32 -0700 Subject: brd: return 0/-error from brd_insert_page() From: Jens Axboe <axboe@xxxxxxxxx> commit db0ccc44a20b4bb3039c0f6885a1f9c3323c7673 upstream. It currently returns a page, but callers just check for NULL/page to gauge success. Clean this up and return the appropriate error directly instead. Cc: stable@xxxxxxxxxxxxxxx # 5.10+ Reviewed-by: Christoph Hellwig <hch@xxxxxx> Signed-off-by: Jens Axboe <axboe@xxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/block/brd.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) --- a/drivers/block/brd.c +++ b/drivers/block/brd.c @@ -78,11 +78,9 @@ static struct page *brd_lookup_page(stru } /* - * Look up and return a brd's page for a given sector. - * If one does not exist, allocate an empty page, and insert that. Then - * return it. + * Insert a new page for a given sector, if one does not already exist. */ -static struct page *brd_insert_page(struct brd_device *brd, sector_t sector) +static int brd_insert_page(struct brd_device *brd, sector_t sector) { pgoff_t idx; struct page *page; @@ -90,7 +88,7 @@ static struct page *brd_insert_page(stru page = brd_lookup_page(brd, sector); if (page) - return page; + return 0; /* * Must use NOIO because we don't want to recurse back into the @@ -99,11 +97,11 @@ static struct page *brd_insert_page(stru gfp_flags = GFP_NOIO | __GFP_ZERO | __GFP_HIGHMEM; page = alloc_page(gfp_flags); if (!page) - return NULL; + return -ENOMEM; if (radix_tree_preload(GFP_NOIO)) { __free_page(page); - return NULL; + return -ENOMEM; } spin_lock(&brd->brd_lock); @@ -120,8 +118,7 @@ static struct page *brd_insert_page(stru spin_unlock(&brd->brd_lock); radix_tree_preload_end(); - - return page; + return 0; } /* @@ -174,16 +171,17 @@ static int copy_to_brd_setup(struct brd_ { unsigned int offset = (sector & (PAGE_SECTORS-1)) << SECTOR_SHIFT; size_t copy; + int ret; copy = min_t(size_t, n, PAGE_SIZE - offset); - if (!brd_insert_page(brd, sector)) - return -ENOSPC; + ret = brd_insert_page(brd, sector); + if (ret) + return ret; if (copy < n) { sector += copy >> SECTOR_SHIFT; - if (!brd_insert_page(brd, sector)) - return -ENOSPC; + ret = brd_insert_page(brd, sector); } - return 0; + return ret; } /* Patches currently in stable-queue which might be from axboe@xxxxxxxxx are queue-6.1/sbitmap-use-single-per-bitmap-counting-to-wake-up-qu.patch queue-6.1/io_uring-handle-tif_notify_resume-when-checking-for-task_work.patch queue-6.1/brd-return-0-error-from-brd_insert_page.patch queue-6.1/fs-hfsplus-fix-uaf-issue-in-hfsplus_put_super.patch queue-6.1/block-don-t-allow-multiple-bios-for-iocb_nowait-issue.patch queue-6.1/sbitmap-correct-wake_batch-recalculation-to-avoid-po.patch queue-6.1/blk-mq-avoid-sleep-in-blk_mq_alloc_request_hctx.patch queue-6.1/io_uring-add-reschedule-point-to-handle_tw_list.patch queue-6.1/ublk_drv-remove-nr_aborted_queues-from-ublk_device.patch queue-6.1/io_uring-remove-msg_nosignal-from-recvmsg.patch queue-6.1/brd-check-for-req_nowait-and-set-correct-page-allocation-mask.patch queue-6.1/io_uring-mark-task-task_running-before-handling-resume-task-work.patch queue-6.1/blk-mq-fix-potential-io-hung-for-shared-sbitmap-per-.patch queue-6.1/blk-mq-wait-on-correct-sbitmap_queue-in-blk_mq_mark_.patch queue-6.1/block-clear-bio-bi_bdev-when-putting-a-bio-back-in-the-cache.patch queue-6.1/io_uring-fix-fget-leak-when-fs-don-t-support-nowait-buffered-read.patch queue-6.1/ublk_drv-don-t-probe-partitions-if-the-ubq-daemon-is.patch queue-6.1/trace-blktrace-fix-memory-leak-with-using-debugfs_lo.patch queue-6.1/io_uring-rsrc-disallow-multi-source-reg-buffers.patch queue-6.1/x86-fpu-don-t-set-tif_need_fpu_load-for-pf_io_worker.patch queue-6.1/io_uring-replace-0-length-array-with-flexible-array.patch queue-6.1/blk-cgroup-dropping-parent-refcount-after-pd_free_fn.patch queue-6.1/block-be-a-bit-more-careful-in-checking-for-null-bdev-while-polling.patch queue-6.1/block-use-proper-return-value-from-bio_failfast.patch queue-6.1/block-fix-io-statistics-for-cgroup-in-throttle-path.patch queue-6.1/block-ublk-check-io-buffer-based-on-flag-need_get_da.patch queue-6.1/io_uring-use-user-visible-tail-in-io_uring_poll.patch queue-6.1/blk-cgroup-synchronize-pd_free_fn-from-blkg_free_wor.patch queue-6.1/sbitmap-remove-redundant-check-in-__sbitmap_queue_ge.patch queue-6.1/block-sync-mixed-merged-request-s-failfast-with-1st-.patch queue-6.1/blk-mq-remove-stale-comment-for-blk_mq_sched_mark_re.patch queue-6.1/brd-mark-as-nowait-compatible.patch queue-6.1/blk-iocost-fix-divide-by-0-error-in-calc_lcoefs.patch queue-6.1/s390-dasd-fix-potential-memleak-in-dasd_eckd_init.patch queue-6.1/blk-mq-correct-stale-comment-of-.get_budget.patch queue-6.1/io_uring-add-a-conditional-reschedule-to-the-iopoll-cancelation-loop.patch queue-6.1/block-bio-integrity-copy-flags-when-bio_integrity_pa.patch