lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <551D5352.8060305@nod.at>
Date:	Thu, 02 Apr 2015 16:33:54 +0200
From:	Richard Weinberger <richard@....at>
To:	Fabio Estevam <festevam@...il.com>
CC:	Brian Norris <computersforpeace@...il.com>,
	"linux-mtd@...ts.infradead.org" <linux-mtd@...ts.infradead.org>,
	David Woodhouse <dwmw2@...radead.org>,
	linux-kernel <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] mtd: Add simple read disturb test

Am 02.04.2015 um 16:32 schrieb Fabio Estevam:
> On Thu, Apr 2, 2015 at 11:13 AM, Richard Weinberger <richard@....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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ