From: Dan Carpenter <dan.carpenter@oracle.com>
To: m@bjorling.me
Cc: linux-block@vger.kernel.org
Subject: re: lightnvm: core on-disk initialization
Date: Tue, 31 May 2016 14:07:11 +0300 [thread overview]
Message-ID: <20160531110711.GA16633@mwanda> (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:422 nvm_get_sysblock()
warn: missing error code here? 'kzalloc()' failed.
drivers/lightnvm/sysblk.c
390 int nvm_get_sysblock(struct nvm_dev *dev, struct nvm_sb_info *info)
391 {
392 struct ppa_addr sysblk_ppas[MAX_SYSBLKS];
393 struct sysblk_scan s;
394 struct nvm_system_block *cur;
395 int i, j, found = 0;
396 int ret = -ENOMEM;
^^^^^^^^^^^^^
Not useful.
397
398 /*
399 * 1. setup sysblk locations
400 * 2. get bad block list
401 * 3. filter on host-specific (type 3)
402 * 4. iterate through all and find the highest seq nr.
403 * 5. return superblock information
404 */
405
406 if (!dev->ops->get_bb_tbl)
407 return -EINVAL;
408
409 nvm_setup_sysblk_scan(dev, &s, sysblk_ppas);
410
411 mutex_lock(&dev->mlock);
412 ret = nvm_get_all_sysblks(dev, &s, sysblk_ppas, 0);
413 if (ret)
414 goto err_sysblk;
415
416 /* no sysblocks initialized */
417 if (!s.nr_ppas)
418 goto err_sysblk;
Should this be an error? Presumably no.
419
420 cur = kzalloc(sizeof(struct nvm_system_block), GFP_KERNEL);
421 if (!cur)
422 goto err_sysblk;
This definitely should be.
423
424 /* find the latest block across all sysblocks */
425 for (i = 0; i < s.nr_rows; i++) {
426 for (j = 0; j < MAX_BLKS_PR_SYSBLK; j++) {
427 struct ppa_addr ppa = s.ppas[scan_ppa_idx(i, j)];
428
429 ret = nvm_scan_block(dev, &ppa, cur);
430 if (ret > 0)
431 found = 1;
432 else if (ret < 0)
433 break;
434 }
435 }
436
437 nvm_sysblk_to_cpu(info, cur);
438
439 kfree(cur);
440 err_sysblk:
This label name is confusing. Better to call it something like
err_unlock.
441 mutex_unlock(&dev->mlock);
442
443 if (found)
444 return 1;
445 return ret;
446 }
regards,
dan carpenter
reply other threads:[~2016-05-31 11:07 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20160531110711.GA16633@mwanda \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.