diff --git a/patches.suse/bcache-fix-error-info-in-register_bcache-d55f.patch b/patches.suse/bcache-fix-error-info-in-register_bcache-d55f.patch new file mode 100644 index 0000000..e404a4c --- /dev/null +++ b/patches.suse/bcache-fix-error-info-in-register_bcache-d55f.patch @@ -0,0 +1,63 @@ +From d55f7cb2e5c053010d2b527494da9bbb722a78ba Mon Sep 17 00:00:00 2001 +From: Chao Yu +Date: Wed, 20 Oct 2021 22:38:07 +0800 +Subject: [PATCH] bcache: fix error info in register_bcache() +Git-commit: d55f7cb2e5c053010d2b527494da9bbb722a78ba +Patch-mainline: v5.16-rc1 +References: git-fixes + +In register_bcache(), there are several cases we didn't set +correct error info (return value and/or error message): +- if kzalloc() fails, it needs to return ENOMEM and print +"cannot allocate memory"; +- if register_cache() fails, it's better to propagate its +return value rather than using default EINVAL. + +Signed-off-by: Chao Yu +Reviewed-by: Hannes Reinecke +Signed-off-by: Coly Li +Link: https://lore.kernel.org/r/20211020143812.6403-4-colyli@suse.de +Signed-off-by: Jens Axboe + +--- + drivers/md/bcache/super.c | 13 ++++++++++--- + 1 file changed, 10 insertions(+), 3 deletions(-) + +diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c +index 330d6c167265..62b0140b0a73 100644 +--- a/drivers/md/bcache/super.c ++++ b/drivers/md/bcache/super.c +@@ -2617,8 +2617,11 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr, + if (SB_IS_BDEV(sb)) { + struct cached_dev *dc = kzalloc(sizeof(*dc), GFP_KERNEL); + +- if (!dc) ++ if (!dc) { ++ ret = -ENOMEM; ++ err = "cannot allocate memory"; + goto out_put_sb_page; ++ } + + mutex_lock(&bch_register_lock); + ret = register_bdev(sb, sb_disk, bdev, dc); +@@ -2629,11 +2632,15 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr, + } else { + struct cache *ca = kzalloc(sizeof(*ca), GFP_KERNEL); + +- if (!ca) ++ if (!ca) { ++ ret = -ENOMEM; ++ err = "cannot allocate memory"; + goto out_put_sb_page; ++ } + + /* blkdev_put() will be called in bch_cache_release() */ +- if (register_cache(sb, sb_disk, bdev, ca) != 0) ++ ret = register_cache(sb, sb_disk, bdev, ca); ++ if (ret) + goto out_free_sb; + } + +-- +2.35.3 + diff --git a/series.conf b/series.conf index feda2b7..0b6786d 100644 --- a/series.conf +++ b/series.conf @@ -6709,6 +6709,7 @@ patches.suse/nvme-move-command-clear-into-the-various-setup-helpe.patch patches.suse/nvme-don-t-memset-the-normal-read-write-command.patch patches.suse/nbd-Fix-use-after-free-in-pid_show.patch + patches.suse/bcache-fix-error-info-in-register_bcache-d55f.patch patches.suse/nvme-generate-uevent-once-a-multipath-namespace-is-o.patch patches.suse/nvme-fc-add-support-for-map_queues.patch patches.suse/qla2xxx-add-map_queues-support-for-nvme.patch