From: Zijun Hu <quic_zijuhu@xxxxxxxxxxx> of_device_uevent_modalias() saves MODALIAS value from offset (@env->buflen - 1), so the available buffer size should be (sizeof(@env->buf) - @env->buflen + 1), but it uses the wrong size (sizeof(@env->buf) - @env->buflen). Fix by using right size (sizeof(@env->buf) - @env->buflen + 1). Fixes: dd27dcda37f0 ("of/device: merge of_device_uevent") Signed-off-by: Zijun Hu <quic_zijuhu@xxxxxxxxxxx> --- drivers/of/device.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/of/device.c b/drivers/of/device.c index edf3be1972658f6dc165f577da53b10c7eebc116..ee29c07c83b9e6abd9b1c7747dd341026bc79eb0 100644 --- a/drivers/of/device.c +++ b/drivers/of/device.c @@ -266,10 +266,10 @@ int of_device_uevent_modalias(const struct device *dev, struct kobj_uevent_env * return -ENOMEM; sl = of_modalias(dev->of_node, &env->buf[env->buflen-1], - sizeof(env->buf) - env->buflen); + sizeof(env->buf) - env->buflen + 1); if (sl < 0) return sl; - if (sl >= (sizeof(env->buf) - env->buflen)) + if (sl >= (sizeof(env->buf) - env->buflen + 1)) return -ENOMEM; env->buflen += sl; -- 2.34.1