lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAE-0n50U47OKs50bOf91HoOayVJEj=H6P-cpyZ_46pX8CVZ4BQ@mail.gmail.com>
Date:   Wed, 13 Dec 2023 16:59:04 -0800
From:   Stephen Boyd <swboyd@...omium.org>
To:     Jonathan Cameron <jic23@...nel.org>,
        Justin Stitt <justinstitt@...gle.com>,
        Lars-Peter Clausen <lars@...afoo.de>
Cc:     linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org,
        linux-hardening@...r.kernel.org
Subject: Re: [PATCH v3] iio: sx9324: avoid copying property strings

Quoting Justin Stitt (2023-12-11 16:42:52)
> diff --git a/drivers/iio/proximity/sx9324.c b/drivers/iio/proximity/sx9324.c
> index 438f9c9aba6e..e3bc30b57b19 100644
> --- a/drivers/iio/proximity/sx9324.c
> +++ b/drivers/iio/proximity/sx9324.c
> @@ -873,6 +873,32 @@ static int sx9324_init_compensation(struct iio_dev *indio_dev)
>                                         20000, 2000000);
>  }
>
> +static u32 sx9324_parse_phase_prop(struct device *dev,

return u8? because that's the type of struct sx_common_reg_default::def.

> +                                  struct sx_common_reg_default *reg_def,
> +                                  int idx, const char *prop)
> +{
> +       unsigned int pin_defs[SX9324_NUM_PINS];
> +       int count, ret, pin;
> +       u8 default_def;
> +       u32 raw = 0;
> +
> +       default_def = sx9324_default_regs[idx].def;

Do we need to do this? Isn't this reg_def->def?

> +
> +       count = device_property_count_u32(dev, prop);
> +       if (count != ARRAY_SIZE(pin_defs))
> +               return default_def;

return reg_def->def?

> +       ret = device_property_read_u32_array(dev, prop, pin_defs,
> +                                            ARRAY_SIZE(pin_defs));
> +       if (ret)
> +               return default_def;

return reg_def->def?

> +
> +       for (pin = 0; pin < SX9324_NUM_PINS; pin++)
> +               raw |= (pin_defs[pin] << (2 * pin)) &
> +                      SX9324_REG_AFE_PH0_PIN_MASK(pin);
> +
> +       return raw;
> +}
> +
>  static const struct sx_common_reg_default *
>  sx9324_get_default_reg(struct device *dev, int idx,
>                        struct sx_common_reg_default *reg_def)
> @@ -884,35 +910,30 @@ sx9324_get_default_reg(struct device *dev, int idx,
>  #define SX9324_PIN_DEF "semtech,ph0-pin"
>  #define SX9324_RESOLUTION_DEF "semtech,ph01-resolution"
>  #define SX9324_PROXRAW_DEF "semtech,ph01-proxraw-strength"

Can you send a followup to remove these defines?

> -       unsigned int pin_defs[SX9324_NUM_PINS];
> -       char prop[] = SX9324_PROXRAW_DEF;
> +       const char *prop = SX9324_PROXRAW_DEF;

This can be left unassigned now, right?

>         u32 start = 0, raw = 0, pos = 0;
> -       int ret, count, ph, pin;
>         const char *res;
> +       int ret;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ