[bug report] UBIFS: add new flash file system

Dan Carpenter dan.carpenter at oracle.com
Tue Feb 21 10:23:44 PST 2017


Hello Artem Bityutskiy,

The patch 1e51764a3c2a: "UBIFS: add new flash file system" from Jul
14, 2008, leads to the following static checker warning:

	fs/ubifs/sb.c:408 validate_sb()
	warn: we tested 'c->main_lebs < (3 + 6)' before and it was 'false'

fs/ubifs/sb.c
   380          if (c->log_lebs < UBIFS_MIN_LOG_LEBS ||
   381              c->lpt_lebs < UBIFS_MIN_LPT_LEBS ||
   382              c->orph_lebs < UBIFS_MIN_ORPH_LEBS ||
   383              c->main_lebs < UBIFS_MIN_MAIN_LEBS) {
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
We should delete this right?

   384                  err = 4;
   385                  goto failed;
   386          }
   387  
   388          /*
   389           * Calculate minimum allowed amount of main area LEBs. This is very
   390           * similar to %UBIFS_MIN_LEB_CNT, but we take into account real what we
   391           * have just read from the superblock.
   392           */
   393          min_leb_cnt = UBIFS_SB_LEBS + UBIFS_MST_LEBS + c->log_lebs;
   394          min_leb_cnt += c->lpt_lebs + c->orph_lebs + c->jhead_cnt + 6;
   395  
   396          if (c->leb_cnt < min_leb_cnt || c->leb_cnt > c->vi.size) {
   397                  ubifs_err(c, "bad LEB count: %d in superblock, %d on UBI volume, %d minimum required",
   398                            c->leb_cnt, c->vi.size, min_leb_cnt);
   399                  goto failed;
   400          }
   401  
   402          if (c->max_leb_cnt < c->leb_cnt) {
   403                  ubifs_err(c, "max. LEB count %d less than LEB count %d",
   404                            c->max_leb_cnt, c->leb_cnt);
   405                  goto failed;
   406          }
   407  
   408          if (c->main_lebs < UBIFS_MIN_MAIN_LEBS) {
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Because this is a duplicate, except we don't set "err = 4".

   409                  ubifs_err(c, "too few main LEBs count %d, must be at least %d",
   410                            c->main_lebs, UBIFS_MIN_MAIN_LEBS);
   411                  goto failed;
   412          }

regards,
dan carpenter



More information about the linux-mtd mailing list