File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -465,7 +465,7 @@ static inline bool is_rst_area_valid(const struct RESTART_HDR *rhdr)
465465{
466466 const struct RESTART_AREA * ra ;
467467 u16 cl , fl , ul ;
468- u32 off , l_size , file_dat_bits , file_size_round ;
468+ u32 off , l_size , seq_bits ;
469469 u16 ro = le16_to_cpu (rhdr -> ra_off );
470470 u32 sys_page = le32_to_cpu (rhdr -> sys_page_size );
471471
@@ -511,13 +511,15 @@ static inline bool is_rst_area_valid(const struct RESTART_HDR *rhdr)
511511 /* Make sure the sequence number bits match the log file size. */
512512 l_size = le64_to_cpu (ra -> l_size );
513513
514- file_dat_bits = sizeof (u64 ) * 8 - le32_to_cpu (ra -> seq_num_bits );
515- file_size_round = 1u << (file_dat_bits + 3 );
516- if (file_size_round != l_size &&
517- (file_size_round < l_size || (file_size_round / 2 ) > l_size )) {
518- return false;
514+ seq_bits = sizeof (u64 ) * 8 + 3 ;
515+ while (l_size ) {
516+ l_size >>= 1 ;
517+ seq_bits -= 1 ;
519518 }
520519
520+ if (seq_bits != ra -> seq_num_bits )
521+ return false;
522+
521523 /* The log page data offset and record header length must be quad-aligned. */
522524 if (!IS_ALIGNED (le16_to_cpu (ra -> data_off ), 8 ) ||
523525 !IS_ALIGNED (le16_to_cpu (ra -> rec_hdr_len ), 8 ))
You can’t perform that action at this time.
0 commit comments