From: kernel test robot <lkp@intel.com>
To: oe-kbuild@lists.linux.dev
Cc: lkp@intel.com, Dan Carpenter <error27@gmail.com>
Subject: block/blk-cgroup.c:845 blkg_conf_open_bdev_frozen() error: we previously assumed 'ctx->bdev' could be null (see line 832)
Date: Fri, 17 Oct 2025 03:07:45 +0800 [thread overview]
Message-ID: <202510170324.JVGAvxHk-lkp@intel.com> (raw)
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
CC: linux-kernel@vger.kernel.org
TO: Nilay Shroff <nilay@linux.ibm.com>
CC: Jens Axboe <axboe@kernel.dk>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 7ea30958b3054f5e488fa0b33c352723f7ab3a2a
commit: 9730763f4756e32520cb86778331465e8d063a8f block: correct locking order for protecting blk-wbt parameters
date: 7 months ago
:::::: branch date: 21 hours ago
:::::: commit date: 7 months ago
config: x86_64-randconfig-161-20251016 (https://download.01.org/0day-ci/archive/20251017/202510170324.JVGAvxHk-lkp@intel.com/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202510170324.JVGAvxHk-lkp@intel.com/
smatch warnings:
block/blk-cgroup.c:845 blkg_conf_open_bdev_frozen() error: we previously assumed 'ctx->bdev' could be null (see line 832)
vim +845 block/blk-cgroup.c
faffaab2895914a Tejun Heo 2023-04-12 767
faffaab2895914a Tejun Heo 2023-04-12 768 /**
faffaab2895914a Tejun Heo 2023-04-12 769 * blkg_conf_open_bdev - parse and open bdev for per-blkg config update
faffaab2895914a Tejun Heo 2023-04-12 770 * @ctx: blkg_conf_ctx initialized with blkg_conf_init()
015d254cb02b6d8 Tejun Heo 2019-08-28 771 *
faffaab2895914a Tejun Heo 2023-04-12 772 * Parse the device node prefix part, MAJ:MIN, of per-blkg config update from
faffaab2895914a Tejun Heo 2023-04-12 773 * @ctx->input and get and store the matching bdev in @ctx->bdev. @ctx->body is
faffaab2895914a Tejun Heo 2023-04-12 774 * set to point past the device node prefix.
015d254cb02b6d8 Tejun Heo 2019-08-28 775 *
faffaab2895914a Tejun Heo 2023-04-12 776 * This function may be called multiple times on @ctx and the extra calls become
faffaab2895914a Tejun Heo 2023-04-12 777 * NOOPs. blkg_conf_prep() implicitly calls this function. Use this function
faffaab2895914a Tejun Heo 2023-04-12 778 * explicitly if bdev access is needed without resolving the blkcg / policy part
faffaab2895914a Tejun Heo 2023-04-12 779 * of @ctx->input. Returns -errno on error.
015d254cb02b6d8 Tejun Heo 2019-08-28 780 */
faffaab2895914a Tejun Heo 2023-04-12 781 int blkg_conf_open_bdev(struct blkg_conf_ctx *ctx)
015d254cb02b6d8 Tejun Heo 2019-08-28 782 {
faffaab2895914a Tejun Heo 2023-04-12 783 char *input = ctx->input;
015d254cb02b6d8 Tejun Heo 2019-08-28 784 unsigned int major, minor;
22ae8ce8b89241c Christoph Hellwig 2020-11-26 785 struct block_device *bdev;
22ae8ce8b89241c Christoph Hellwig 2020-11-26 786 int key_len;
015d254cb02b6d8 Tejun Heo 2019-08-28 787
faffaab2895914a Tejun Heo 2023-04-12 788 if (ctx->bdev)
faffaab2895914a Tejun Heo 2023-04-12 789 return 0;
faffaab2895914a Tejun Heo 2023-04-12 790
015d254cb02b6d8 Tejun Heo 2019-08-28 791 if (sscanf(input, "%u:%u%n", &major, &minor, &key_len) != 2)
faffaab2895914a Tejun Heo 2023-04-12 792 return -EINVAL;
015d254cb02b6d8 Tejun Heo 2019-08-28 793
015d254cb02b6d8 Tejun Heo 2019-08-28 794 input += key_len;
015d254cb02b6d8 Tejun Heo 2019-08-28 795 if (!isspace(*input))
faffaab2895914a Tejun Heo 2023-04-12 796 return -EINVAL;
015d254cb02b6d8 Tejun Heo 2019-08-28 797 input = skip_spaces(input);
015d254cb02b6d8 Tejun Heo 2019-08-28 798
22ae8ce8b89241c Christoph Hellwig 2020-11-26 799 bdev = blkdev_get_no_open(MKDEV(major, minor));
22ae8ce8b89241c Christoph Hellwig 2020-11-26 800 if (!bdev)
faffaab2895914a Tejun Heo 2023-04-12 801 return -ENODEV;
22ae8ce8b89241c Christoph Hellwig 2020-11-26 802 if (bdev_is_partition(bdev)) {
22ae8ce8b89241c Christoph Hellwig 2020-11-26 803 blkdev_put_no_open(bdev);
faffaab2895914a Tejun Heo 2023-04-12 804 return -ENODEV;
015d254cb02b6d8 Tejun Heo 2019-08-28 805 }
015d254cb02b6d8 Tejun Heo 2019-08-28 806
a13bd91be223187 Yu Kuai 2023-04-14 807 mutex_lock(&bdev->bd_queue->rq_qos_mutex);
a13bd91be223187 Yu Kuai 2023-04-14 808 if (!disk_live(bdev->bd_disk)) {
a13bd91be223187 Yu Kuai 2023-04-14 809 blkdev_put_no_open(bdev);
a13bd91be223187 Yu Kuai 2023-04-14 810 mutex_unlock(&bdev->bd_queue->rq_qos_mutex);
a13bd91be223187 Yu Kuai 2023-04-14 811 return -ENODEV;
a13bd91be223187 Yu Kuai 2023-04-14 812 }
a13bd91be223187 Yu Kuai 2023-04-14 813
faffaab2895914a Tejun Heo 2023-04-12 814 ctx->body = input;
faffaab2895914a Tejun Heo 2023-04-12 815 ctx->bdev = bdev;
faffaab2895914a Tejun Heo 2023-04-12 816 return 0;
015d254cb02b6d8 Tejun Heo 2019-08-28 817 }
9730763f4756e32 Nilay Shroff 2025-03-19 818 /*
9730763f4756e32 Nilay Shroff 2025-03-19 819 * Similar to blkg_conf_open_bdev, but additionally freezes the queue,
9730763f4756e32 Nilay Shroff 2025-03-19 820 * acquires q->elevator_lock, and ensures the correct locking order
9730763f4756e32 Nilay Shroff 2025-03-19 821 * between q->elevator_lock and q->rq_qos_mutex.
9730763f4756e32 Nilay Shroff 2025-03-19 822 *
9730763f4756e32 Nilay Shroff 2025-03-19 823 * This function returns negative error on failure. On success it returns
9730763f4756e32 Nilay Shroff 2025-03-19 824 * memflags which must be saved and later passed to blkg_conf_exit_frozen
9730763f4756e32 Nilay Shroff 2025-03-19 825 * for restoring the memalloc scope.
9730763f4756e32 Nilay Shroff 2025-03-19 826 */
9730763f4756e32 Nilay Shroff 2025-03-19 827 unsigned long __must_check blkg_conf_open_bdev_frozen(struct blkg_conf_ctx *ctx)
9730763f4756e32 Nilay Shroff 2025-03-19 828 {
9730763f4756e32 Nilay Shroff 2025-03-19 829 int ret;
9730763f4756e32 Nilay Shroff 2025-03-19 830 unsigned long memflags;
9730763f4756e32 Nilay Shroff 2025-03-19 831
9730763f4756e32 Nilay Shroff 2025-03-19 @832 if (ctx->bdev)
9730763f4756e32 Nilay Shroff 2025-03-19 833 return -EINVAL;
9730763f4756e32 Nilay Shroff 2025-03-19 834
9730763f4756e32 Nilay Shroff 2025-03-19 835 ret = blkg_conf_open_bdev(ctx);
9730763f4756e32 Nilay Shroff 2025-03-19 836 if (ret < 0)
9730763f4756e32 Nilay Shroff 2025-03-19 837 return ret;
9730763f4756e32 Nilay Shroff 2025-03-19 838 /*
9730763f4756e32 Nilay Shroff 2025-03-19 839 * At this point, we haven’t started protecting anything related to QoS,
9730763f4756e32 Nilay Shroff 2025-03-19 840 * so we release q->rq_qos_mutex here, which was first acquired in blkg_
9730763f4756e32 Nilay Shroff 2025-03-19 841 * conf_open_bdev. Later, we re-acquire q->rq_qos_mutex after freezing
9730763f4756e32 Nilay Shroff 2025-03-19 842 * the queue and acquiring q->elevator_lock to maintain the correct
9730763f4756e32 Nilay Shroff 2025-03-19 843 * locking order.
9730763f4756e32 Nilay Shroff 2025-03-19 844 */
9730763f4756e32 Nilay Shroff 2025-03-19 @845 mutex_unlock(&ctx->bdev->bd_queue->rq_qos_mutex);
9730763f4756e32 Nilay Shroff 2025-03-19 846
9730763f4756e32 Nilay Shroff 2025-03-19 847 memflags = blk_mq_freeze_queue(ctx->bdev->bd_queue);
9730763f4756e32 Nilay Shroff 2025-03-19 848 mutex_lock(&ctx->bdev->bd_queue->elevator_lock);
9730763f4756e32 Nilay Shroff 2025-03-19 849 mutex_lock(&ctx->bdev->bd_queue->rq_qos_mutex);
9730763f4756e32 Nilay Shroff 2025-03-19 850
9730763f4756e32 Nilay Shroff 2025-03-19 851 return memflags;
9730763f4756e32 Nilay Shroff 2025-03-19 852 }
015d254cb02b6d8 Tejun Heo 2019-08-28 853
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
next reply other threads:[~2025-10-16 19:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-16 19:07 kernel test robot [this message]
-- strict thread matches above, loose matches on Subject: below --
2026-01-26 1:14 block/blk-cgroup.c:845 blkg_conf_open_bdev_frozen() error: we previously assumed 'ctx->bdev' could be null (see line 832) kernel test robot
2025-07-03 3:33 kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=202510170324.JVGAvxHk-lkp@intel.com \
--to=lkp@intel.com \
--cc=error27@gmail.com \
--cc=oe-kbuild@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.