Skip to content

Commit cefa1aa

Browse files
Dan Carpentermiquelraynal
authored andcommitted
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: 3b270fa ("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
1 parent a5e393c commit cefa1aa

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

drivers/mtd/mtdcore.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -975,12 +975,14 @@ static int mtd_otp_nvmem_add(struct mtd_info *mtd)
975975
void *otp;
976976

977977
otp = kmalloc(size, GFP_KERNEL);
978-
if (!otp)
979-
return -ENOMEM;
978+
if (!otp) {
979+
err = -ENOMEM;
980+
goto err;
981+
}
980982
err = mtd_nvmem_fact_otp_reg_read(mtd, 0, otp, size);
981983
if (err < 0) {
982984
kfree(otp);
983-
return err;
985+
goto err;
984986
}
985987
add_device_randomness(otp, err);
986988
kfree(otp);

0 commit comments

Comments
 (0)