@@ -538,7 +538,7 @@ int ubi_leb_write(struct ubi_volume_desc *desc, int lnum, const void *buf,
538
538
if (desc -> mode == UBI_READONLY || vol -> vol_type == UBI_STATIC_VOLUME )
539
539
return - EROFS ;
540
540
541
- if (lnum < 0 || lnum >= vol -> reserved_pebs || offset < 0 || len < 0 ||
541
+ if (! ubi_leb_valid ( vol , lnum ) || offset < 0 || len < 0 ||
542
542
offset + len > vol -> usable_leb_size ||
543
543
offset & (ubi -> min_io_size - 1 ) || len & (ubi -> min_io_size - 1 ))
544
544
return - EINVAL ;
@@ -583,7 +583,7 @@ int ubi_leb_change(struct ubi_volume_desc *desc, int lnum, const void *buf,
583
583
if (desc -> mode == UBI_READONLY || vol -> vol_type == UBI_STATIC_VOLUME )
584
584
return - EROFS ;
585
585
586
- if (lnum < 0 || lnum >= vol -> reserved_pebs || len < 0 ||
586
+ if (! ubi_leb_valid ( vol , lnum ) || len < 0 ||
587
587
len > vol -> usable_leb_size || len & (ubi -> min_io_size - 1 ))
588
588
return - EINVAL ;
589
589
@@ -620,7 +620,7 @@ int ubi_leb_erase(struct ubi_volume_desc *desc, int lnum)
620
620
if (desc -> mode == UBI_READONLY || vol -> vol_type == UBI_STATIC_VOLUME )
621
621
return - EROFS ;
622
622
623
- if (lnum < 0 || lnum >= vol -> reserved_pebs )
623
+ if (! ubi_leb_valid ( vol , lnum ) )
624
624
return - EINVAL ;
625
625
626
626
if (vol -> upd_marker )
@@ -680,7 +680,7 @@ int ubi_leb_unmap(struct ubi_volume_desc *desc, int lnum)
680
680
if (desc -> mode == UBI_READONLY || vol -> vol_type == UBI_STATIC_VOLUME )
681
681
return - EROFS ;
682
682
683
- if (lnum < 0 || lnum >= vol -> reserved_pebs )
683
+ if (! ubi_leb_valid ( vol , lnum ) )
684
684
return - EINVAL ;
685
685
686
686
if (vol -> upd_marker )
@@ -716,7 +716,7 @@ int ubi_leb_map(struct ubi_volume_desc *desc, int lnum)
716
716
if (desc -> mode == UBI_READONLY || vol -> vol_type == UBI_STATIC_VOLUME )
717
717
return - EROFS ;
718
718
719
- if (lnum < 0 || lnum >= vol -> reserved_pebs )
719
+ if (! ubi_leb_valid ( vol , lnum ) )
720
720
return - EINVAL ;
721
721
722
722
if (vol -> upd_marker )
@@ -751,7 +751,7 @@ int ubi_is_mapped(struct ubi_volume_desc *desc, int lnum)
751
751
752
752
dbg_gen ("test LEB %d:%d" , vol -> vol_id , lnum );
753
753
754
- if (lnum < 0 || lnum >= vol -> reserved_pebs )
754
+ if (! ubi_leb_valid ( vol , lnum ) )
755
755
return - EINVAL ;
756
756
757
757
if (vol -> upd_marker )
0 commit comments