[PATCH linux dev-4.10] hwmon (occ): Fix integer overflow in multiplication
mine260309 at gmail.com
Tue Dec 19 13:27:22 AEDT 2017
Except for the values for power, the value used for temperature is u16
Powercore reports that if the temperature goes over 65 degrees, the
obviously as long as it is over 65535.
Could you fix this as well?
On Mon, Dec 18, 2017 at 10:11 PM, Joel Stanley <joel at jms.id.au> wrote:
> On Sat, Dec 9, 2017 at 8:47 AM, Eddie James <eajames at linux.vnet.ibm.com> wrote:
>> On 12/08/2017 12:16 AM, Joel Stanley wrote:
>>> On Thu, Dec 7, 2017 at 5:49 AM, Eddie James <eajames at linux.vnet.ibm.com>
>>>> --- a/drivers/hwmon/occ/common.c
>>>> +++ b/drivers/hwmon/occ/common.c
>>>> @@ -468,7 +468,7 @@ static ssize_t occ_show_power_1(struct device *dev,
>>>> struct device_attribute *attr, char
>>>> int rc;
>>>> - u32 val = 0;
>>>> + u64 val = 0;
>>>> struct power_sensor_1 *power;
>>>> struct occ *occ = dev_get_drvdata(dev);
>>>> struct occ_sensors *sensors = &occ->sensors;
>>>> @@ -491,11 +491,11 @@ static ssize_t occ_show_power_1(struct device *dev,
>>>> val = get_unaligned_be32(&power->accumulator);
>>>> case 3:
>>>> - val = get_unaligned_be16(&power->value) * 1000000;
>>>> + val = (u64)get_unaligned_be16(&power->value) *
>>> I don't think these casts are required, are they?
>> I'm not at all sure. I didn't think adding ULL was required here, but
>> apparently it is. I don't really trust GCC...
> Sorry, I thought you were joking here. GCC is behaving as it should.
> Hit me up on IRC for an explanation sometime.
> Can you resend without the casts?
More information about the openbmc