[PATCH 1/2] peci: fix error-handling in peci_dev_ioctl()
Zev Weiss
zev at bewilderbeest.net
Sun Sep 27 07:27:33 AEST 2020
peci_get_xfer_msg() returns NULL on failure, not an ERR_PTR. Also
avoid calling kfree() on an ERR_PTR.
Signed-off-by: Zev Weiss <zev at bewilderbeest.net>
---
drivers/peci/peci-dev.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/peci/peci-dev.c b/drivers/peci/peci-dev.c
index e0fe09467a80..84e90af81ccc 100644
--- a/drivers/peci/peci-dev.c
+++ b/drivers/peci/peci-dev.c
@@ -122,8 +122,8 @@ static long peci_dev_ioctl(struct file *file, uint iocmd, ulong arg)
}
xmsg = peci_get_xfer_msg(uxmsg.tx_len, uxmsg.rx_len);
- if (IS_ERR(xmsg)) {
- ret = PTR_ERR(xmsg);
+ if (!xmsg) {
+ ret = -ENOMEM;
break;
}
@@ -162,7 +162,8 @@ static long peci_dev_ioctl(struct file *file, uint iocmd, ulong arg)
}
peci_put_xfer_msg(xmsg);
- kfree(msg);
+ if (!IS_ERR(msg))
+ kfree(msg);
return (long)ret;
}
--
2.28.0
More information about the openbmc
mailing list