mtd: otp: clean up on error in mtd_otp_nvmem_add()
Smatch complains that these error paths are missing cleanup:
drivers/mtd/mtdcore.c:983 mtd_otp_nvmem_add()
warn: missing unwind goto?
This needs to call nvmem_unregister(mtd->otp_user_nvmem) before
returning.
Fixes: 3b270fac84
("mtd: otp: Put factory OTP/NVRAM into the entropy pool")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/fe7ef901-9571-4c6e-a40e-449046efe2c6@moroto.mountain
This commit is contained in:
parent
a5e393c1e8
commit
cefa1aaa31
|
@ -975,12 +975,14 @@ static int mtd_otp_nvmem_add(struct mtd_info *mtd)
|
|||
void *otp;
|
||||
|
||||
otp = kmalloc(size, GFP_KERNEL);
|
||||
if (!otp)
|
||||
return -ENOMEM;
|
||||
if (!otp) {
|
||||
err = -ENOMEM;
|
||||
goto err;
|
||||
}
|
||||
err = mtd_nvmem_fact_otp_reg_read(mtd, 0, otp, size);
|
||||
if (err < 0) {
|
||||
kfree(otp);
|
||||
return err;
|
||||
goto err;
|
||||
}
|
||||
add_device_randomness(otp, err);
|
||||
kfree(otp);
|
||||
|
|
Loading…
Reference in New Issue