mirror of
https://github.com/torvalds/linux.git
synced 2026-05-24 07:03:03 +02:00
mtd: rawnand: omap2: fix device leak on probe failure
Make sure to drop the reference to the elm device taken by
of_find_device_by_node() during probe on errors and on driver unload.
Fixes: 62116e5171 ("mtd: nand: omap2: Support for hardware BCH error correction.")
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
This commit is contained in:
parent
8ed4728eb9
commit
fa1f26b48f
|
|
@ -1979,7 +1979,7 @@ static int omap_nand_attach_chip(struct nand_chip *chip)
|
|||
err = rawnand_sw_bch_init(chip);
|
||||
if (err) {
|
||||
dev_err(dev, "Unable to use BCH library\n");
|
||||
return err;
|
||||
goto err_put_elm_dev;
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
@ -2016,7 +2016,7 @@ static int omap_nand_attach_chip(struct nand_chip *chip)
|
|||
err = rawnand_sw_bch_init(chip);
|
||||
if (err) {
|
||||
dev_err(dev, "unable to use BCH library\n");
|
||||
return err;
|
||||
goto err_put_elm_dev;
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
@ -2054,7 +2054,8 @@ static int omap_nand_attach_chip(struct nand_chip *chip)
|
|||
break;
|
||||
default:
|
||||
dev_err(dev, "Invalid or unsupported ECC scheme\n");
|
||||
return -EINVAL;
|
||||
err = -EINVAL;
|
||||
goto err_put_elm_dev;
|
||||
}
|
||||
|
||||
if (elm_bch_strength >= 0) {
|
||||
|
|
@ -2073,7 +2074,7 @@ static int omap_nand_attach_chip(struct nand_chip *chip)
|
|||
info->nsteps_per_eccpg, chip->ecc.size,
|
||||
chip->ecc.bytes);
|
||||
if (err < 0)
|
||||
return err;
|
||||
goto err_put_elm_dev;
|
||||
}
|
||||
|
||||
/* Check if NAND device's OOB is enough to store ECC signatures */
|
||||
|
|
@ -2083,10 +2084,24 @@ static int omap_nand_attach_chip(struct nand_chip *chip)
|
|||
dev_err(dev,
|
||||
"Not enough OOB bytes: required = %d, available=%d\n",
|
||||
min_oobbytes, mtd->oobsize);
|
||||
return -EINVAL;
|
||||
err = -EINVAL;
|
||||
goto err_put_elm_dev;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
err_put_elm_dev:
|
||||
put_device(info->elm_dev);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static void omap_nand_detach_chip(struct nand_chip *chip)
|
||||
{
|
||||
struct mtd_info *mtd = nand_to_mtd(chip);
|
||||
struct omap_nand_info *info = mtd_to_omap(mtd);
|
||||
|
||||
put_device(info->elm_dev);
|
||||
}
|
||||
|
||||
static void omap_nand_data_in(struct nand_chip *chip, void *buf,
|
||||
|
|
@ -2187,6 +2202,7 @@ static int omap_nand_exec_op(struct nand_chip *chip,
|
|||
|
||||
static const struct nand_controller_ops omap_nand_controller_ops = {
|
||||
.attach_chip = omap_nand_attach_chip,
|
||||
.detach_chip = omap_nand_detach_chip,
|
||||
.exec_op = omap_nand_exec_op,
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user