[mtd-next:master 11/11] drivers/mtd/mtdcore.c:1786:29-32: ERROR: reference preceded by free on line 1784 (fwd)

Julia Lawall julia.lawall at lip6.fr
Thu Dec 1 12:00:27 PST 2016


It's a false positive from Coccinelle, but I wonder if it's really worth
it.  Perhaps the code would be simpler with if (ret) { kfree(bdi); return
ERR_PTR(ret); } return bdi;

julia



tree:   git://git.infradead.org/linux-mtd-next.git master
head:   445caaa20c4d6da74f426464f90513b81157ad77
commit: 445caaa20c4d6da74f426464f90513b81157ad77 [11/11] mtd: Allocate bdi objects dynamically
:::::: branch date: 2 hours ago
:::::: commit date: 2 hours ago

>> drivers/mtd/mtdcore.c:1786:29-32: ERROR: reference preceded by free on line 1784

git remote add mtd-next git://git.infradead.org/linux-mtd-next.git
git remote update mtd-next
git checkout 445caaa20c4d6da74f426464f90513b81157ad77
vim +1786 drivers/mtd/mtdcore.c

445caaa2 Steve Longerbeam 2016-08-04  1778  	bdi = kzalloc(sizeof(*bdi), GFP_KERNEL);
445caaa2 Steve Longerbeam 2016-08-04  1779  	if (!bdi)
445caaa2 Steve Longerbeam 2016-08-04  1780  		return ERR_PTR(-ENOMEM);
0661b1ac Jens Axboe       2010-04-27  1781
445caaa2 Steve Longerbeam 2016-08-04  1782  	ret = bdi_setup_and_register(bdi, name);
0661b1ac Jens Axboe       2010-04-27  1783  	if (ret)
445caaa2 Steve Longerbeam 2016-08-04 @1784  		kfree(bdi);
0661b1ac Jens Axboe       2010-04-27  1785
445caaa2 Steve Longerbeam 2016-08-04 @1786  	return ret ? ERR_PTR(ret) : bdi;
694bb7fc Kevin Cernekee   2009-04-03  1787  }
0661b1ac Jens Axboe       2010-04-27  1788
93e56214 Artem Bityutskiy 2013-03-15  1789  static struct proc_dir_entry *proc_mtd;

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation



More information about the linux-mtd mailing list