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]
Date: Tue, 30 Apr 2024 23:33:15 +0300
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: Alisa-Dariana Roman <alisadariana@...il.com>
Cc: michael.hennerich@...log.com, linux-iio@...r.kernel.org, 
	devicetree@...r.kernel.org, linux-kernel@...r.kernel.org, 
	alexandru.tachici@...log.com, lars@...afoo.de, jic23@...nel.org, 
	robh@...nel.org, krzysztof.kozlowski+dt@...aro.org, conor+dt@...nel.org, 
	lgirdwood@...il.com, broonie@...nel.org, andy@...nel.org, nuno.sa@...log.com, 
	marcelo.schmitt@...log.com, bigunclemax@...il.com, dlechner@...libre.com, 
	okan.sahin@...log.com, fr0st61te@...il.com, alisa.roman@...log.com, 
	marcus.folkesson@...il.com, schnelle@...ux.ibm.com, liambeguin@...il.com
Subject: Re: [PATCH v7 6/6] iio: adc: ad7192: Add AD7194 support

On Tue, Apr 30, 2024 at 7:30 PM Alisa-Dariana Roman
<alisadariana@...il.com> wrote:
>
> Unlike the other AD719Xs, AD7194 has configurable channels. The user can
> dynamically configure them in the devicetree.
>
> Also modify config AD7192 description for better scaling.

..

> +static int ad7194_parse_channels(struct iio_dev *indio_dev)
> +{
> +       struct device *dev = indio_dev->dev.parent;
> +       struct iio_chan_spec *ad7194_channels;
> +       struct fwnode_handle *child;
> +       struct iio_chan_spec ad7194_chan = AD7193_CHANNEL(0, 0, 0);
> +       struct iio_chan_spec ad7194_chan_diff = AD7193_DIFF_CHANNEL(0, 0, 0, 0);
> +       struct iio_chan_spec ad7194_chan_temp = AD719x_TEMP_CHANNEL(0, 0);
> +       struct iio_chan_spec ad7194_chan_timestamp = IIO_CHAN_SOFT_TIMESTAMP(0);
> +       unsigned int num_channels, index = 0;
> +       u32 ain[2];
> +       int ret;
> +
> +       num_channels = device_get_child_node_count(dev);
> +       if (num_channels > AD7194_CH_MAX_NR)
> +               return dev_err_probe(dev, -EINVAL,
> +                                    "Too many channels: %u\n", num_channels);
> +
> +       num_channels += AD7194_CH_BASE_NR;
> +
> +       ad7194_channels = devm_kcalloc(dev, num_channels,
> +                                      sizeof(*ad7194_channels), GFP_KERNEL);
> +       if (!ad7194_channels)
> +               return -ENOMEM;
> +
> +       indio_dev->channels = ad7194_channels;
> +       indio_dev->num_channels = num_channels;
> +
> +       device_for_each_child_node(dev, child) {

You wanted _scoped version...

> +               ret = fwnode_property_read_u32_array(child, "diff-channels",
> +                                                    ain, ARRAY_SIZE(ain));
> +               if (ret == 0) {
> +                       ret = ad7194_validate_ain_channel(dev, ain[0]);
> +                       if (ret)

..otherwise here is the reference count leakage.

> +                               return ret;
> +
> +                       ret = ad7194_validate_ain_channel(dev, ain[1]);
> +                       if (ret)

Or here.

> +                               return ret;
> +
> +                       *ad7194_channels = ad7194_chan_diff;
> +                       ad7194_channels->scan_index = index++;
> +                       ad7194_channels->channel = ain[0];
> +                       ad7194_channels->channel2 = ain[1];
> +                       ad7194_channels->address = AD7194_CH(ain[0], ain[1]);
> +               } else {
> +                       ret = fwnode_property_read_u32(child, "single-channel",
> +                                                      &ain[0]);
> +                       if (ret) {
> +                               fwnode_handle_put(child);
> +                               return ret;
> +                       }
> +
> +                       ret = ad7194_validate_ain_channel(dev, ain[0]);
> +                       if (ret)

Or here.

> +                               return ret;
> +
> +                       *ad7194_channels = ad7194_chan;
> +                       ad7194_channels->scan_index = index++;
> +                       ad7194_channels->channel = ain[0];
> +                       ad7194_channels->address = AD7194_CH(ain[0], 0);
> +               }
> +               ad7194_channels++;
> +       }
> +
> +       *ad7194_channels = ad7194_chan_temp;
> +       ad7194_channels->scan_index = index++;
> +       ad7194_channels->address = AD7194_CH_TEMP;
> +       ad7194_channels++;
> +
> +       *ad7194_channels = ad7194_chan_timestamp;
> +       ad7194_channels->scan_index = index;
> +
> +       return 0;
> +}

-- 
With Best Regards,
Andy Shevchenko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ