linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Richard Weinberger <richard@nod.at>
To: Fabio Estevam <festevam@gmail.com>
Cc: David Woodhouse <dwmw2@infradead.org>,
	Brian Norris <computersforpeace@gmail.com>,
	"linux-mtd@lists.infradead.org" <linux-mtd@lists.infradead.org>,
	linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] mtd: Add simple read disturb test
Date: Thu, 02 Apr 2015 16:33:54 +0200	[thread overview]
Message-ID: <551D5352.8060305@nod.at> (raw)
In-Reply-To: <CAOMZO5AeuCJB5anOt9Rq_H-HsLhXR9VZz0PDkN=R6aRPZN=+0g@mail.gmail.com>

Am 02.04.2015 um 16:32 schrieb Fabio Estevam:
> On Thu, Apr 2, 2015 at 11:13 AM, Richard Weinberger <richard@nod.at> wrote:
> 
>> +       err = -ENOMEM;
>> +       iobuf = kmalloc(mtd->erasesize, GFP_KERNEL);
>> +       if (!iobuf)
>> +               goto out;
> 
> The error handling here does not look right.
> 
>> +
>> +       iobuf_orig = kmalloc(mtd->erasesize, GFP_KERNEL);
>> +       if (!iobuf_orig)
>> +               goto out;
>> +
>> +       prandom_bytes_state(&rnd_state, iobuf_orig, mtd->erasesize);
>> +
>> +       bit_flips = kcalloc(ebcnt, sizeof(unsigned long), GFP_KERNEL);
>> +       if (!bit_flips)
>> +               goto out;
>> +
>> +       bbt = kzalloc(ebcnt, GFP_KERNEL);
>> +       if (!bbt)
>> +               goto out;
>> +
>> +       err = mtdtest_scan_for_bad_eraseblocks(mtd, bbt, 0, ebcnt);
>> +       if (err)
>> +               goto out;
>> +
>> +       pr_info("erasing and programming flash\n");
>> +       for (i = 0; i < ebcnt; ++i) {
>> +               if (skip_blocks && i % skip_blocks != 0)
>> +                       continue;
>> +
>> +               if (bbt[i])
>> +                       continue;
>> +
>> +               ret = mtdtest_erase_eraseblock(mtd, i);
>> +               if (ret) {
>> +                       err = ret;
>> +                       goto out;
>> +               }
>> +
>> +               ret = mtdtest_write(mtd, i * mtd->erasesize, mtd->erasesize,
>> +                                   iobuf_orig);
>> +               if (ret) {
>> +                       err = ret;
>> +                       goto out;
>> +               }
>> +
>> +               ret = mtdtest_relax();
>> +               if (ret)
>> +                       goto out;
>> +       }
>> +
>> +       pr_info("starting read disturb test on every %ith block\n",
>> +               skip_blocks);
>> +       while (!ret) {
>> +               for (i = 0; i < ebcnt; ++i) {
>> +                       if (skip_blocks && i % skip_blocks != 0)
>> +                               continue;
>> +
>> +                       if (bbt[i])
>> +                               continue;
>> +
>> +                       ret = read_eraseblock_by_page(i, iteration);
>> +
>> +                       ret = mtdtest_relax();
>> +                       if (ret)
>> +                               goto out;
>> +               }
>> +
>> +               iteration++;
>> +               if (iteration % 1000 == 0)
>> +                       pr_info("iteration %lu started\n", iteration);
>> +       }
>> +
>> +       if (err)
>> +               pr_info("finished with errors\n");
>> +       else
>> +               pr_info("finished\n");
>> +
>> +out:
>> +
>> +       kfree(bit_flips);
>> +       kfree(iobuf);
>> +       kfree(iobuf_orig);
>> +       kfree(bbt);
> 
> ,as you have a single label to handle all the free's.

Why? Free()ing a NULL pointer is perfectly fine.
What did I miss? :)

Thanks,
//richard

  reply	other threads:[~2015-04-02 14:34 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-02 14:13 [PATCH] mtd: Add simple read disturb test Richard Weinberger
2015-04-02 14:32 ` Fabio Estevam
2015-04-02 14:33   ` Richard Weinberger [this message]
2015-04-02 14:45     ` Fabio Estevam
2015-04-02 14:56       ` Richard Weinberger
2015-04-02 15:03         ` Fabio Estevam
2015-04-02 15:19           ` Richard Weinberger
2015-04-02 15:29   ` Richard Weinberger
2015-04-02 15:02 ` Fabio Estevam
2015-04-02 15:18   ` Richard Weinberger
2015-04-02 16:04 ` Brian Norris
2015-04-02 16:18   ` Richard Weinberger
2015-04-03  5:19     ` Andrea Scian
2015-04-12 19:31     ` Boris Brezillon
2015-10-13  0:11       ` Brian Norris
2015-10-19 21:11         ` Richard Weinberger
2015-10-20 13:22         ` Ezequiel Garcia
     [not found] <mailman.39315.1427996116.22890.linux-mtd@lists.infradead.org>

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=551D5352.8060305@nod.at \
    --to=richard@nod.at \
    --cc=computersforpeace@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=festevam@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    /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;
as well as URLs for NNTP newsgroup(s).