[bug report] thermal/drivers/mediatek: Add the Low Voltage Thermal Sensor driver
Balsam CHIHI
bchihi at baylibre.com
Thu Mar 2 06:23:37 PST 2023
On Mon, Feb 27, 2023 at 12:26 PM Dan Carpenter <error27 at gmail.com> wrote:
>
> Hello Balsam CHIHI,
>
> The patch f5f633b18234: "thermal/drivers/mediatek: Add the Low
> Voltage Thermal Sensor driver" from Feb 9, 2023, leads to the
> following Smatch static checker warning:
>
> drivers/thermal/mediatek/lvts_thermal.c:562 lvts_calibration_init()
> warn: not copying enough bytes for '&lvts_ctrl->calibration[i]' (4 vs 2 bytes)
>
> drivers/thermal/mediatek/lvts_thermal.c
> 555 static int lvts_calibration_init(struct device *dev, struct lvts_ctrl *lvts_ctrl,
> 556 const struct lvts_ctrl_data *lvts_ctrl_data,
> 557 u8 *efuse_calibration)
> 558 {
> 559 int i;
> 560
> 561 for (i = 0; i < lvts_ctrl_data->num_lvts_sensor; i++)
> --> 562 memcpy(&lvts_ctrl->calibration[i],
> 563 efuse_calibration + lvts_ctrl_data->cal_offset[i], 2);
> ^
> This is copying an array of known ints to a u32 array. It should copy
> sizeof(int) instead of 2. It only works because the data you're on
> little endian and the data is small.
>
> 564
> 565 return 0;
> 566 }
>
> regards,
> dan carpenter
Hello Dan Carpenter,
Thank you for reporting this bug.
I will create a patch to fix it ASAP.
Best regards,
Balsam
More information about the Linux-mediatek
mailing list