diff mbox series

[-next,v2] tpm: of: fix return value check in tpm_read_log_memory_region()

Message ID 20230130121240.3344618-1-yangyingliang@huawei.com (mailing list archive)
State New, archived
Headers show
Series [-next,v2] tpm: of: fix return value check in tpm_read_log_memory_region() | expand

Commit Message

Yang Yingliang Jan. 30, 2023, 12:12 p.m. UTC
devm_memremap() never returns NULL pointer, it will return
ERR_PTR() when it fails, so replace the check with IS_ERR().

Fixes: b0474a20b153 ("tpm: Add reserved memory event log")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
v1 -> v2:
  Change the return value to PTR_ERR().
 drivers/char/tpm/eventlog/of.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series


diff --git a/drivers/char/tpm/eventlog/of.c b/drivers/char/tpm/eventlog/of.c
index c815cadf00a4..a25a5a2d4b35 100644
--- a/drivers/char/tpm/eventlog/of.c
+++ b/drivers/char/tpm/eventlog/of.c
@@ -43,9 +43,9 @@  static int tpm_read_log_memory_region(struct tpm_chip *chip)
 	chip->log.bios_event_log = devm_memremap(&chip->dev, res.start, resource_size(&res),
-	if (!chip->log.bios_event_log) {
+	if (IS_ERR(chip->log.bios_event_log)) {
 		dev_info(&chip->dev, "err memremap\n");
-		return -ENOMEM;
+		return PTR_ERR(chip->log.bios_event_log);
 	chip->log.bios_event_log_end = chip->log.bios_event_log + resource_size(&res);