Re: [PATCH] damon: vaddr-test: fix a missing check on list iterator
From: Xiaomeng Tong
Date: Mon Mar 28 2022 - 07:45:26 EST
On Mon, 28 Mar 2022 07:51:04 +0000, SJ wrote:
> On Sun, 27 Mar 2022 16:03:45 +0800 Xiaomeng Tong <xiam0nd.tong@xxxxxxxxx> wrote:
>
> > The bug is here:
> > KUNIT_EXPECT_EQ(test, r->ar.start, start + i * expected_width);
> > KUNIT_EXPECT_EQ(test, r->ar.end, end);
> >
> > For the damon_for_each_region(), just like list_for_each_entry(),
> > the list iterator 'drm_crtc' will point to a bogus position
> > containing HEAD if the list is empty or no element is found.
> > This case must be checked before any use of the iterator,
> > otherwise it will lead to a invalid memory access.
>
> We ensure 'damon_va_evenly_split_region()' successes before executing the loop,
> so the issue cannot occur. That said, I think this patch makes code better to
> read. Could you please resend this patch after fixing the commit message?
Yes, you should be right. I have resend this patch with the commit message changed.
Please check it, thank you.
--
Xiaomeng Tong