In nanddev_init mtd and memorg are assigned values that dereference nand
but this happens before a NULL check for nand. Move the assignments
after the NULL check.
This issue was found by Smatch.
Signed-off-by: Andrew Goodbody <andrew.goodbody@linaro.org>
Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
int nanddev_init(struct nand_device *nand, const struct nand_ops *ops,
struct module *owner)
{
- struct mtd_info *mtd = nanddev_to_mtd(nand);
- struct nand_memory_organization *memorg = nanddev_get_memorg(nand);
+ struct mtd_info *mtd;
+ struct nand_memory_organization *memorg;
if (!nand || !ops)
return -EINVAL;
if (!ops->erase || !ops->markbad || !ops->isbad)
return -EINVAL;
+ mtd = nanddev_to_mtd(nand);
+ memorg = nanddev_get_memorg(nand);
+
if (!memorg->bits_per_cell || !memorg->pagesize ||
!memorg->pages_per_eraseblock || !memorg->eraseblocks_per_lun ||
!memorg->planes_per_lun || !memorg->luns_per_target ||