From f7e7a3f151020b4138619f02d30709cf30cc7ff2 Mon Sep 17 00:00:00 2001 From: Alice Guo Date: Fri, 9 May 2025 10:43:13 +0800 Subject: [PATCH] LF-15138-2 nvmem: imx-ocotp-fsb-s400: fix the bug caused by not getting the se-fw2 device When not getting the se-fw2 device, calling read_common_fuse() or ele_write_fuse() will result in segmentation fault because fuse->se_dev is a NULL pointer. Check fuse->se_dev to avoid this error. Signed-off-by: Alice Guo Reviewed-by: Peng Fan Acked-by: Jason Liu --- drivers/nvmem/imx-ocotp-fsb-s400.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/nvmem/imx-ocotp-fsb-s400.c b/drivers/nvmem/imx-ocotp-fsb-s400.c index 5019afc5cd54..2beaff62e734 100644 --- a/drivers/nvmem/imx-ocotp-fsb-s400.c +++ b/drivers/nvmem/imx-ocotp-fsb-s400.c @@ -395,6 +395,11 @@ static int imx_fsb_s400_fuse_probe(struct platform_device *pdev) } fuse->se_dev = get_se_dev(fuse->hw->se_pdev_name); + if (IS_ERR_OR_NULL(fuse->se_dev)) { + dev_err(&pdev->dev, "failed to get the se-fw2 device\n"); + return -EPROBE_DEFER; + } + dev_dbg(&pdev->dev, "fuse nvmem device registered successfully\n"); return 0;