Message ID | 20230307165359.225361-2-miquel.raynal@bootlin.com |
---|---|
State | Accepted |
Commit | b19a4266c52de78496fe40f0b37580a3b762e67d |
Headers | show |
Series | [v2,01/21] of: Fix modalias string generation | expand |
diff --git a/drivers/of/device.c b/drivers/of/device.c index c674a13c3055..877f50379fab 100644 --- a/drivers/of/device.c +++ b/drivers/of/device.c @@ -297,12 +297,15 @@ int of_device_request_module(struct device *dev) if (size < 0) return size; - str = kmalloc(size + 1, GFP_KERNEL); + /* Reserve an additional byte for the trailing '\0' */ + size++; + + str = kmalloc(size, GFP_KERNEL); if (!str) return -ENOMEM; of_device_get_modalias(dev, str, size); - str[size] = '\0'; + str[size - 1] = '\0'; ret = request_module(str); kfree(str);