From: Christoph Hellwig Date: Tue, 8 Sep 2020 14:15:06 +0000 (+0200) Subject: block: restore a specific error code in bdev_del_partition X-Git-Tag: v5.8.10~130 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b730cc810f71f7b2126d390b63b981e744777c35;p=thirdparty%2Fkernel%2Fstable.git block: restore a specific error code in bdev_del_partition [ Upstream commit 88ce2a530cc9865a894454b2e40eba5957a60e1a ] mdadm relies on the fact that deleting an invalid partition returns -ENXIO or -ENOTTY to detect if a block device is a partition or a whole device. Fixes: 08fc1ab6d748 ("block: fix locking in bdev_del_partition") Reported-by: kernel test robot Signed-off-by: Christoph Hellwig Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- diff --git a/block/partitions/core.c b/block/partitions/core.c index 534e11285a8d4..b45539764c994 100644 --- a/block/partitions/core.c +++ b/block/partitions/core.c @@ -529,7 +529,7 @@ int bdev_del_partition(struct block_device *bdev, int partno) bdevp = bdget_disk(bdev->bd_disk, partno); if (!bdevp) - return -ENOMEM; + return -ENXIO; mutex_lock(&bdevp->bd_mutex); mutex_lock_nested(&bdev->bd_mutex, 1);