* [bug report] thermal/drivers/mediatek: Add the Low Voltage Thermal Sensor driver
@ 2023-02-27 11:26 Dan Carpenter
2023-03-02 14:23 ` Balsam CHIHI
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2023-02-27 11:26 UTC (permalink / raw)
To: bchihi; +Cc: linux-pm, linux-mediatek
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [bug report] thermal/drivers/mediatek: Add the Low Voltage Thermal Sensor driver
2023-02-27 11:26 [bug report] thermal/drivers/mediatek: Add the Low Voltage Thermal Sensor driver Dan Carpenter
@ 2023-03-02 14:23 ` Balsam CHIHI
0 siblings, 0 replies; 2+ messages in thread
From: Balsam CHIHI @ 2023-03-02 14:23 UTC (permalink / raw)
To: Dan Carpenter; +Cc: linux-pm, linux-mediatek
On Mon, Feb 27, 2023 at 12:26 PM Dan Carpenter <error27@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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-03-02 14:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-27 11:26 [bug report] thermal/drivers/mediatek: Add the Low Voltage Thermal Sensor driver Dan Carpenter
2023-03-02 14:23 ` Balsam CHIHI
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox