mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] drivers: stm: correct the index in master array release
@ 2016-01-28  4:21 Chunyan Zhang
  2016-02-09 10:12 ` Alexander Shishkin
  0 siblings, 1 reply; 4+ messages in thread
From: Chunyan Zhang @ 2016-01-28  4:21 UTC (permalink / raw)
  To: alexander.shishkin; +Cc: linux-kernel, mathieu.poirier, zhang.lyra

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.

Signed-off-by: Chunyan Zhang <zhang.chunyan@linaro.org>
---
 drivers/hwtracing/stm/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hwtracing/stm/core.c b/drivers/hwtracing/stm/core.c
index da53b5d..80e7b5e 100644
--- a/drivers/hwtracing/stm/core.c
+++ b/drivers/hwtracing/stm/core.c
@@ -718,7 +718,7 @@ void stm_unregister_device(struct stm_data *stm_data)
 		stp_policy_unbind(stm->policy);
 	mutex_unlock(&stm->policy_mutex);
 
-	for (i = 0; i < stm->sw_nmasters; i++)
+	for (i = stm->data->sw_start; i <= stm->data->sw_end; i++)
 		stp_master_free(stm, i);
 
 	device_unregister(&stm->dev);
-- 
1.9.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] drivers: stm: correct the index in master array release
  2016-01-28  4:21 [PATCH] drivers: stm: correct the index in master array release Chunyan Zhang
@ 2016-02-09 10:12 ` Alexander Shishkin
  2016-02-14  6:25   ` Chunyan Zhang
  0 siblings, 1 reply; 4+ messages in thread
From: Alexander Shishkin @ 2016-02-09 10:12 UTC (permalink / raw)
  To: Chunyan Zhang; +Cc: linux-kernel, mathieu.poirier, zhang.lyra

Chunyan Zhang <zhang.chunyan@linaro.org> 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.

Regards,
--
Alex

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] drivers: stm: correct the index in master array release
  2016-02-09 10:12 ` Alexander Shishkin
@ 2016-02-14  6:25   ` Chunyan Zhang
  2016-02-15 10:34     ` Alexander Shishkin
  0 siblings, 1 reply; 4+ messages in thread
From: Chunyan Zhang @ 2016-02-14  6:25 UTC (permalink / raw)
  To: Alexander Shishkin; +Cc: linux-kernel, Mathieu Poirier, Lyra Zhang

On Tue, Feb 9, 2016 at 6:12 PM, Alexander Shishkin
<alexander.shishkin@linux.intel.com> wrote:
> Chunyan Zhang <zhang.chunyan@linaro.org> 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.
That's what I wanted to address in this patch. I meant the number of
loop in stm_unregister_device() is correct, but the start index isn't.
Sorry for not describing clear enough in the patch logs.

Thanks,
Chunyan

>
> Regards,
> --
> Alex

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] drivers: stm: correct the index in master array release
  2016-02-14  6:25   ` Chunyan Zhang
@ 2016-02-15 10:34     ` Alexander Shishkin
  0 siblings, 0 replies; 4+ messages in thread
From: Alexander Shishkin @ 2016-02-15 10:34 UTC (permalink / raw)
  To: Chunyan Zhang; +Cc: linux-kernel, Mathieu Poirier, Lyra Zhang

Chunyan Zhang <zhang.chunyan@linaro.org> writes:

> On Tue, Feb 9, 2016 at 6:12 PM, Alexander Shishkin
> <alexander.shishkin@linux.intel.com> wrote:
>> Chunyan Zhang <zhang.chunyan@linaro.org> 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-02-15 10:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-28  4:21 [PATCH] drivers: stm: correct the index in master array release Chunyan Zhang
2016-02-09 10:12 ` Alexander Shishkin
2016-02-14  6:25   ` Chunyan Zhang
2016-02-15 10:34     ` Alexander Shishkin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®