On 8/13/24 8:19 PM, Guenter Roeck wrote:
On Sun, Aug 11, 2024 at 02:14:41AM +0200, Maximilian Luz wrote:
Some of the newer Microsoft Surface devices (such as the Surface Book
3 and Pro 9) have thermal sensors connected via the Surface Aggregator
Module (the embedded controller on those devices). Add a basic driver
to read out the temperature values of those sensors.
The EC can have up to 16 thermal sensors connected via a single
sub-device, each providing temperature readings and a label string.
Link: https://github.com/linux-surface/surface-aggregator-module/issues/59
Reviewed-by: Hans de Goede <hdegoede@xxxxxxxxxx>
Co-developed-by: Ivor Wanders <ivor@xxxxxxxxxxxx>
Signed-off-by: Ivor Wanders <ivor@xxxxxxxxxxxx>
Signed-off-by: Maximilian Luz <luzmaximilian@xxxxxxxxx>
Applied. One comment below, though.
---
+
+ /*
+ * This should not fail unless the name in the returned struct is not
+ * null-terminated or someone changed something in the struct
+ * definitions above, since our buffer and struct have the same
+ * capacity by design. So if this fails, log an error message. Since
+ * the more likely cause is that the returned string isn't
+ * null-terminated, we might have received garbage (as opposed to just
+ * an incomplete string), so also fail the function.
+ */
+ status = strscpy(buf, name_rsp.name, buf_len);
+ if (status < 0) {
+ dev_err(&sdev->dev, "received non-null-terminated sensor name string\n");
+ return status;
+ }
If that ever happens, it will likely be permanent and clog the kernel log.
Normally I'd ask you to make it _once, but I am kind of tired right now of
having to explain to people that clogging the kernel log isn't really a
good idea - even more so if the message doesn't provide any real value.
Ah, I didn't even think about that. I can send in a follow-up patch if
you want me to.
Currently it should be fine since we are failing the whole driver if
this does not work out. But using dev_err_once() would be more
forward-thinking in case we ever change that.
Thanks!
Best regards,
Max