of: device: Do not ignore error code in of_device_uevent_modalias

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>
Reviewed-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20230207110531.1060252-3-alexander.stein@ew.tq-group.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Alexander Stein 2023-02-07 12:05:30 +01:00 committed by Greg Kroah-Hartman
parent 553bd29700
commit 2295bed9be

View File

@ -385,6 +385,8 @@ int of_device_uevent_modalias(struct device *dev, struct kobj_uevent_env *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;