[PATCH linux dev-4.10] hwmon (occ): Fix integer overflow in multiplication

Joel Stanley joel at jms.id.au
Fri Dec 8 17:16:26 AEDT 2017


On Thu, Dec 7, 2017 at 5:49 AM, Eddie James <eajames at linux.vnet.ibm.com> wrote:
> --- 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 *buf)
>  {
>         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);
>                 break;
>         case 3:
> -               val = get_unaligned_be16(&power->value) * 1000000;
> +               val = (u64)get_unaligned_be16(&power->value) * 1000000ULL;

I don't think these casts are required, are they?


More information about the openbmc mailing list