summaryrefslogtreecommitdiffstats
path: root/drivers/ptp/ptp_ocp.c
diff options
context:
space:
mode:
authorJonathan Lemon <jonathan.lemon@gmail.com>2022-03-29 09:03:54 -0700
committerJakub Kicinski <kuba@kernel.org>2022-03-30 12:08:11 -0700
commit8f0588e80e33273c2fa219da4622affab0cdd22f (patch)
tree9c13159d424cccf740ca9113b5bf4cb10ce2603f /drivers/ptp/ptp_ocp.c
parent866b7a278cdb51eb158cd8513bc7438fc857804a (diff)
downloadlinux-8f0588e80e33273c2fa219da4622affab0cdd22f.tar.bz2
ptp: ocp: handle error from nvmem_device_find
nvmem_device_find returns a valid pointer or IS_ERR(). Handle this properly. Fixes: 0cfcdd1ebcfe ("ptp: ocp: add nvmem interface for accessing eeprom") Signed-off-by: Jonathan Lemon <jonathan.lemon@gmail.com> Link: https://lore.kernel.org/r/20220329160354.4035-1-jonathan.lemon@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'drivers/ptp/ptp_ocp.c')
-rw-r--r--drivers/ptp/ptp_ocp.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
index c3d0fcf609e3..0feaa4b45317 100644
--- a/drivers/ptp/ptp_ocp.c
+++ b/drivers/ptp/ptp_ocp.c
@@ -1214,10 +1214,9 @@ ptp_ocp_nvmem_device_get(struct ptp_ocp *bp, const void * const tag)
static inline void
ptp_ocp_nvmem_device_put(struct nvmem_device **nvmemp)
{
- if (*nvmemp != NULL) {
+ if (!IS_ERR_OR_NULL(*nvmemp))
nvmem_device_put(*nvmemp);
- *nvmemp = NULL;
- }
+ *nvmemp = NULL;
}
static void
@@ -1241,13 +1240,15 @@ ptp_ocp_read_eeprom(struct ptp_ocp *bp)
}
if (!nvmem) {
nvmem = ptp_ocp_nvmem_device_get(bp, tag);
- if (!nvmem)
- goto out;
+ if (IS_ERR(nvmem)) {
+ ret = PTR_ERR(nvmem);
+ goto fail;
+ }
}
ret = nvmem_device_read(nvmem, map->off, map->len,
BP_MAP_ENTRY_ADDR(bp, map));
if (ret != map->len)
- goto read_fail;
+ goto fail;
}
bp->has_eeprom_data = true;
@@ -1256,7 +1257,7 @@ out:
ptp_ocp_nvmem_device_put(&nvmem);
return;
-read_fail:
+fail:
dev_err(&bp->pdev->dev, "could not read eeprom: %d\n", ret);
goto out;
}