diff mbox series

[2/3] of: device: Do not ignore error code in of_device_uevent_modalias

Message ID 20230207110531.1060252-3-alexander.stein@ew.tq-group.com (mailing list archive)
State Accepted
Commit 2295bed9bebe8d1eef276194fed5b5fbe89c5363
Headers show
Series Fix ehci-fsl autoload regression on fsl-mph-dr-of | expand

Commit Message

Alexander Stein Feb. 7, 2023, 11:05 a.m. UTC
of_device_get_modalias might return an error code, propagate that one.
Otherwise the negative, signed integer is propagated to unsigned integer
for the comparison resulting in a huge 'sl' size.

Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
---
There is no problem if of_device_uevent_modalias uses the same checks as
of_device_get_modalias, but this is error prone and cumbersome.

 drivers/of/device.c | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/drivers/of/device.c b/drivers/of/device.c
index 5b929351b65bf..955bfb3d1a834 100644
--- a/drivers/of/device.c
+++ b/drivers/of/device.c
@@ -385,6 +385,8 @@  int of_device_uevent_modalias(const struct device *dev, struct kobj_uevent_env *
 
 	sl = of_device_get_modalias(dev, &env->buf[env->buflen-1],
 				    sizeof(env->buf) - env->buflen);
+	if (sl < 0)
+		return sl;
 	if (sl >= (sizeof(env->buf) - env->buflen))
 		return -ENOMEM;
 	env->buflen += sl;