dcdc2313ba6ab3d40e8b175be669ee864c67e828
[openwrt/staging/neocturne.git] /
1 From 2295bed9bebe8d1eef276194fed5b5fbe89c5363 Mon Sep 17 00:00:00 2001
2 From: Alexander Stein <alexander.stein@ew.tq-group.com>
3 Date: Tue, 7 Feb 2023 12:05:30 +0100
4 Subject: [PATCH] of: device: Do not ignore error code in
5 of_device_uevent_modalias
6
7 of_device_get_modalias might return an error code, propagate that one.
8 Otherwise the negative, signed integer is propagated to unsigned integer
9 for the comparison resulting in a huge 'sl' size.
10
11 Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
12 Reviewed-by: Rob Herring <robh@kernel.org>
13 Link: https://lore.kernel.org/r/20230207110531.1060252-3-alexander.stein@ew.tq-group.com
14 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
15 ---
16 drivers/of/device.c | 2 ++
17 1 file changed, 2 insertions(+)
18
19 --- a/drivers/of/device.c
20 +++ b/drivers/of/device.c
21 @@ -388,6 +388,8 @@ int of_device_uevent_modalias(struct dev
22
23 sl = of_device_get_modalias(dev, &env->buf[env->buflen-1],
24 sizeof(env->buf) - env->buflen);
25 + if (sl < 0)
26 + return sl;
27 if (sl >= (sizeof(env->buf) - env->buflen))
28 return -ENOMEM;
29 env->buflen += sl;