Re: [PATCH v1 09/15] platform/x86: i2c-multi-instantiate: Count I2cSerialBus() resources
From: Andy Shevchenko
Date: Mon Nov 26 2018 - 09:32:53 EST
On Wed, Nov 21, 2018 at 01:03:35PM +0100, Hans de Goede wrote:
> On 20-11-18 16:59, Andy Shevchenko wrote:
> > - multi->num_clients = i;
> > + multi->num_clients = ret;
> > for (i = 0; i < multi->num_clients; i++) {
> > memset(&board_info, 0, sizeof(board_info));
>
> Now you end up indexing inst_data with i without checking that inst_data
> holds enough data. Not using all of inst_data in case there are less
> I2cSerialBus resources then inst_data entries is fine. But you need to
> deal with the case when there are more I2cSerialBus resources then inst_data
> entries, either by erroring out or ignoring the extra I2cSerialBus resources.
I think returning an error here is to be on safer side.
> Also it might be better to make the i2c_multi_inst_count_resources() function
> a generic helper under drivers/acpi, so that it can be used in other places,
> see my comments to the BOSC0200 patch.
I would rather to avoid touching BOSC0200 right now and keep that function
inside i2c-multi-instantiate.
--
With Best Regards,
Andy Shevchenko