Linux block layer
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: m@bjorling.me
Cc: linux-block@vger.kernel.org
Subject: [bug report] lightnvm: core on-disk initialization
Date: Thu, 8 Dec 2016 13:47:32 +0300	[thread overview]
Message-ID: <20161208104731.GA11393@elgon.mountain> (raw)

Hello Matias Bj�rling,

The patch e3eb3799f7e0: "lightnvm: core on-disk initialization" from
Jan 12, 2016, leads to the following static checker warning:

	drivers/lightnvm/sysblk.c:409 nvm_get_sysblock()
	warn: missing error code here? 'kzalloc()' failed.

drivers/lightnvm/sysblk.c
   398          mutex_lock(&dev->mlock);
   399          ret = nvm_get_all_sysblks(dev, &s, sysblk_ppas, 0);
   400          if (ret)
   401                  goto err_sysblk;
   402  
   403          /* no sysblocks initialized */
   404          if (!s.nr_ppas)
   405                  goto err_sysblk;

Do we want to return 0 or an error code here?  I'm not sure.

   406  
   407          cur = kzalloc(sizeof(struct nvm_system_block), GFP_KERNEL);
   408          if (!cur)
   409                  goto err_sysblk;

We should set "ret = -ENOMEM;" before the goto.

   410  
   411          /* find the latest block across all sysblocks */
   412          for (i = 0; i < s.nr_rows; i++) {
   413                  for (j = 0; j < MAX_BLKS_PR_SYSBLK; j++) {
   414                          struct ppa_addr ppa = s.ppas[scan_ppa_idx(i, j)];
   415  
   416                          ret = nvm_scan_block(dev, &ppa, cur);
   417                          if (ret > 0)
   418                                  found = 1;
   419                          else if (ret < 0)
   420                                  break;
   421                  }
   422          }
   423  
   424          nvm_sysblk_to_cpu(info, cur);
   425  
   426          kfree(cur);
   427  err_sysblk:
   428          mutex_unlock(&dev->mlock);
   429  
   430          if (found)
   431                  return 1;
   432          return ret;
   433  }
   434  
   435  int nvm_update_sysblock(struct nvm_dev *dev, struct nvm_sb_info *new)
   436  {
   437          /* 1. for each latest superblock
   438           * 2. if room
   439           *    a. write new flash page entry with the updated information
   440           * 3. if no room
   441           *    a. find next available block on lun (linear search)
   442           *       if none, continue to next lun
   443           *       if none at all, report error. also report that it wasn't
   444           *       possible to write to all superblocks.
   445           *    c. write data to block.
   446           */
   447          struct ppa_addr sysblk_ppas[MAX_SYSBLKS];
   448          struct sysblk_scan s;
   449          struct nvm_system_block *cur;
   450          int i, j, ppaidx, found = 0;
   451          int ret = -ENOMEM;
   452  
   453          if (!dev->ops->get_bb_tbl)
   454                  return -EINVAL;
   455  
   456          nvm_setup_sysblk_scan(dev, &s, sysblk_ppas);
   457  
   458          mutex_lock(&dev->mlock);
   459          ret = nvm_get_all_sysblks(dev, &s, sysblk_ppas, 0);
   460          if (ret)
   461                  goto err_sysblk;
   462  
   463          cur = kzalloc(sizeof(struct nvm_system_block), GFP_KERNEL);
   464          if (!cur)
   465                  goto err_sysblk;

Same here as well.

   466  

regards,
dan carpenter

             reply	other threads:[~2016-12-08 10:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-08 10:47 Dan Carpenter [this message]
2016-12-08 12:06 ` [bug report] lightnvm: core on-disk initialization Matias Bjørling

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161208104731.GA11393@elgon.mountain \
    --to=dan.carpenter@oracle.com \
    --cc=linux-block@vger.kernel.org \
    --cc=m@bjorling.me \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox