2024-02-01 06:39:17

by Li Nan

[permalink] [raw]
Subject: [PATCH v5 3/8] md: clean up invalid BUG_ON in md_ioctl

From: Li Nan <[email protected]>

'disk->private_data' is set to mddev in md_alloc() and never set to NULL,
and users need to open mddev before submitting ioctl. So mddev must not
have been freed during ioctl, and there is no need to check mddev here.
Clean up it.

Signed-off-by: Li Nan <[email protected]>
---
drivers/md/md.c | 5 -----
1 file changed, 5 deletions(-)

diff --git a/drivers/md/md.c b/drivers/md/md.c
index 3b4e0ef49675..656080086052 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -7647,11 +7647,6 @@ static int md_ioctl(struct block_device *bdev, blk_mode_t mode,

mddev = bdev->bd_disk->private_data;

- if (!mddev) {
- BUG();
- goto out;
- }
-
/* Some actions do not requires the mutex */
switch (cmd) {
case GET_ARRAY_INFO:
--
2.39.2



2024-02-02 01:23:10

by Yu Kuai

[permalink] [raw]
Subject: Re: [PATCH v5 3/8] md: clean up invalid BUG_ON in md_ioctl

?? 2024/02/01 14:33, [email protected] ะด??:
> From: Li Nan <[email protected]>
>
> 'disk->private_data' is set to mddev in md_alloc() and never set to NULL,
> and users need to open mddev before submitting ioctl. So mddev must not
> have been freed during ioctl, and there is no need to check mddev here.
> Clean up it.
>
> Signed-off-by: Li Nan <[email protected]>
> ---
> drivers/md/md.c | 5 -----
> 1 file changed, 5 deletions(-)
>
> diff --git a/drivers/md/md.c b/drivers/md/md.c
> index 3b4e0ef49675..656080086052 100644
> --- a/drivers/md/md.c
> +++ b/drivers/md/md.c
> @@ -7647,11 +7647,6 @@ static int md_ioctl(struct block_device *bdev, blk_mode_t mode,
>
> mddev = bdev->bd_disk->private_data;
>
> - if (!mddev) {
> - BUG();

Given that this BUG() never triggered before.

Reviewed-by: Yu Kuai <[email protected]>

> - goto out;
> - }
> -
> /* Some actions do not requires the mutex */
> switch (cmd) {
> case GET_ARRAY_INFO:
>