The check for poll_fds in g_assert() was incorrect. The correct assertion
should check "n_poll_fds + w->num <= ARRAY_SIZE(poll_fds)" because the
subsequent for-loop is doing access to poll_fds[n_poll_fds + i] where i
is in [0, w->num).
Signed-off-by: Lidong Chen <lidong.chen@oracle.com>
Reviewed-by: Liran Alon <liran.alon@oracle.com>
Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
---
util/main-loop.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/util/main-loop.c b/util/main-loop.c
index e1e349c..a9f4e8d 100644
--- a/util/main-loop.c
+++ b/util/main-loop.c
@@ -422,7 +422,7 @@ static int os_host_main_loop_wait(int64_t timeout)
g_main_context_prepare(context, &max_priority);
n_poll_fds = g_main_context_query(context, max_priority, &poll_timeout,
poll_fds, ARRAY_SIZE(poll_fds));
- g_assert(n_poll_fds <= ARRAY_SIZE(poll_fds));
+ g_assert(n_poll_fds + w->num <= ARRAY_SIZE(poll_fds));
for (i = 0; i < w->num; i++) {
poll_fds[n_poll_fds + i].fd = (DWORD_PTR)w->events[i];
--
1.8.3.1
Lidong Chen <lidong.chen@oracle.com> 于2019年6月5日周三 下午2:23写道:
> The check for poll_fds in g_assert() was incorrect. The correct assertion
> should check "n_poll_fds + w->num <= ARRAY_SIZE(poll_fds)" because the
> subsequent for-loop is doing access to poll_fds[n_poll_fds + i] where i
> is in [0, w->num).
>
> Signed-off-by: Lidong Chen <lidong.chen@oracle.com>
> Reviewed-by: Liran Alon <liran.alon@oracle.com>
> Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
>
Reviewed-by: Li Qiang <liq3ea@gmail.com>
Thanks,
Li Qiang
> ---
> util/main-loop.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/util/main-loop.c b/util/main-loop.c
> index e1e349c..a9f4e8d 100644
> --- a/util/main-loop.c
> +++ b/util/main-loop.c
> @@ -422,7 +422,7 @@ static int os_host_main_loop_wait(int64_t timeout)
> g_main_context_prepare(context, &max_priority);
> n_poll_fds = g_main_context_query(context, max_priority,
> &poll_timeout,
> poll_fds, ARRAY_SIZE(poll_fds));
> - g_assert(n_poll_fds <= ARRAY_SIZE(poll_fds));
> + g_assert(n_poll_fds + w->num <= ARRAY_SIZE(poll_fds));
>
> for (i = 0; i < w->num; i++) {
> poll_fds[n_poll_fds + i].fd = (DWORD_PTR)w->events[i];
> --
> 1.8.3.1
>
>
This patch doesn't seem related to the series cover.
On 6/5/19 8:21 AM, Lidong Chen wrote:
> The check for poll_fds in g_assert() was incorrect. The correct assertion
> should check "n_poll_fds + w->num <= ARRAY_SIZE(poll_fds)" because the
> subsequent for-loop is doing access to poll_fds[n_poll_fds + i] where i
> is in [0, w->num).
>
Suggested-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Lidong Chen <lidong.chen@oracle.com>
> Reviewed-by: Liran Alon <liran.alon@oracle.com>
> Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> util/main-loop.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/util/main-loop.c b/util/main-loop.c
> index e1e349c..a9f4e8d 100644
> --- a/util/main-loop.c
> +++ b/util/main-loop.c
> @@ -422,7 +422,7 @@ static int os_host_main_loop_wait(int64_t timeout)
> g_main_context_prepare(context, &max_priority);
> n_poll_fds = g_main_context_query(context, max_priority, &poll_timeout,
> poll_fds, ARRAY_SIZE(poll_fds));
> - g_assert(n_poll_fds <= ARRAY_SIZE(poll_fds));
> + g_assert(n_poll_fds + w->num <= ARRAY_SIZE(poll_fds));
>
> for (i = 0; i < w->num; i++) {
> poll_fds[n_poll_fds + i].fd = (DWORD_PTR)w->events[i];
>
On 6/5/2019 1:57 AM, Philippe Mathieu-Daudé wrote:
> This patch doesn't seem related to the series cover.
I will resent the patch to include more details to the cover.
>
> On 6/5/19 8:21 AM, Lidong Chen wrote:
>> The check for poll_fds in g_assert() was incorrect. The correct assertion
>> should check "n_poll_fds + w->num <= ARRAY_SIZE(poll_fds)" because the
>> subsequent for-loop is doing access to poll_fds[n_poll_fds + i] where i
>> is in [0, w->num).
>>
> Suggested-by: Peter Maydell <peter.maydell@linaro.org>
Liam Merwick also suggested this fix. So, added him as well.
Thanks,
Lidong
>
>> Signed-off-by: Lidong Chen <lidong.chen@oracle.com>
>> Reviewed-by: Liran Alon <liran.alon@oracle.com>
>> Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>
>> ---
>> util/main-loop.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/util/main-loop.c b/util/main-loop.c
>> index e1e349c..a9f4e8d 100644
>> --- a/util/main-loop.c
>> +++ b/util/main-loop.c
>> @@ -422,7 +422,7 @@ static int os_host_main_loop_wait(int64_t timeout)
>> g_main_context_prepare(context, &max_priority);
>> n_poll_fds = g_main_context_query(context, max_priority, &poll_timeout,
>> poll_fds, ARRAY_SIZE(poll_fds));
>> - g_assert(n_poll_fds <= ARRAY_SIZE(poll_fds));
>> + g_assert(n_poll_fds + w->num <= ARRAY_SIZE(poll_fds));
>>
>> for (i = 0; i < w->num; i++) {
>> poll_fds[n_poll_fds + i].fd = (DWORD_PTR)w->events[i];
>>
© 2016 - 2026 Red Hat, Inc.