diff mbox series

ubi: remove dead code in validate_vid_hdr()

Message ID 1608382150-102703-1-git-send-email-zhongjubin@huawei.com
State Accepted
Headers show
Series ubi: remove dead code in validate_vid_hdr() | expand

Commit Message

Jubin Zhong Dec. 19, 2020, 12:49 p.m. UTC
data_size is already checked against zero when vol_type matches
UBI_VID_STATIC. Remove the following dead code.

Signed-off-by: Jubin Zhong <zhongjubin@huawei.com>
---
 drivers/mtd/ubi/io.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

Comments

Richard Weinberger Dec. 20, 2020, 9:15 p.m. UTC | #1
On Sat, Dec 19, 2020 at 1:52 PM Jubin Zhong <zhongjubin@huawei.com> wrote:
>
> data_size is already checked against zero when vol_type matches
> UBI_VID_STATIC. Remove the following dead code.
>
> Signed-off-by: Jubin Zhong <zhongjubin@huawei.com>
> ---
>  drivers/mtd/ubi/io.c | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
>
> diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c
> index 2f3312c..8a7306c 100644
> --- a/drivers/mtd/ubi/io.c
> +++ b/drivers/mtd/ubi/io.c
> @@ -913,12 +913,7 @@ static int validate_vid_hdr(const struct ubi_device *ubi,
>                                 ubi_err(ubi, "bad data_size");
>                                 goto bad;
>                         }
> -               } else if (lnum == used_ebs - 1) {
> -                       if (data_size == 0) {
> -                               ubi_err(ubi, "bad data_size at last LEB");
> -                               goto bad;
> -                       }
> -               } else {
> +               } else if (lnum > used_ebs - 1) {
>                         ubi_err(ubi, "too high lnum");
>                         goto bad;
>                 }
> --

Looks good, applied to my 5.12 queue!
diff mbox series

Patch

diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c
index 2f3312c..8a7306c 100644
--- a/drivers/mtd/ubi/io.c
+++ b/drivers/mtd/ubi/io.c
@@ -913,12 +913,7 @@  static int validate_vid_hdr(const struct ubi_device *ubi,
 				ubi_err(ubi, "bad data_size");
 				goto bad;
 			}
-		} else if (lnum == used_ebs - 1) {
-			if (data_size == 0) {
-				ubi_err(ubi, "bad data_size at last LEB");
-				goto bad;
-			}
-		} else {
+		} else if (lnum > used_ebs - 1) {
 			ubi_err(ubi, "too high lnum");
 			goto bad;
 		}