Re: [PATCH] drivers: stm: correct the index in master array release

From: Alexander Shishkin
Date: Mon Feb 15 2016 - 05:34:18 EST


Chunyan Zhang <zhang.chunyan@xxxxxxxxxx> writes:

> On Tue, Feb 9, 2016 at 6:12 PM, Alexander Shishkin
> <alexander.shishkin@xxxxxxxxxxxxxxx> wrote:
>> Chunyan Zhang <zhang.chunyan@xxxxxxxxxx> writes:
>>
>>> It would be broken if stm_data->sw_start isn't zero, because that
>>> stp_master_free() get the 'master' with __stm_master()/stm_master(),
>>> in which the masterID is the second input parameter minus
>>> stm_data->sw_start. So freeing STM masters has to start from
>>> stm_data->sw_start.
>>
>> No, it won't. stm_master_free() handles nonexistent masters correctly.
>> It does make sense to shrink the loop in stm_unregister_device() to
>> avoid going through the [0..sw_start) range, since stm_master() returns
>> NULL for those, but not for the reasons given in this patch description.
>
> Let's assume sw_start = 64, sw_end = 79, sw_nmasters should be 16, if
> the loop goes through [0..16), the existed masters will not be freed.

Ah yes, you're right, of course.

I'll add this fix to the queue with a proper description.

Thanks,
--
Alex