File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -263,10 +263,23 @@ static size_t _unmap_area(struct rt_aspace *aspace, void *v_addr)
263263 lvl_entry [i ] = ((rt_ubase_t * )aspace -> page_table + lvl_off [i ]);
264264 pentry = lvl_entry [i ];
265265
266+ /* check if lvl_entry[0] is valid. if no, return 0 directly. */
267+ if (!PTE_USED (* pentry ))
268+ {
269+ return 0 ;
270+ }
271+
266272 /* find leaf page table entry */
267273 while (PTE_USED (* pentry ) && !PAGE_IS_LEAF (* pentry ))
268274 {
269275 i += 1 ;
276+
277+ if (i >= 3 )
278+ {
279+ unmapped = 0 ;
280+ break ;
281+ }
282+
270283 lvl_entry [i ] = ((rt_ubase_t * )PPN_TO_VPN (GET_PADDR (* pentry ), PV_OFFSET ) +
271284 lvl_off [i ]);
272285 pentry = lvl_entry [i ];
@@ -278,6 +291,10 @@ static size_t _unmap_area(struct rt_aspace *aspace, void *v_addr)
278291 {
279292 _unmap_pte (pentry , lvl_entry , i );
280293 }
294+ else
295+ {
296+ unmapped = 0 ; /* invalid pte, return 0. */
297+ }
281298
282299 return unmapped ;
283300}
You can’t perform that action at this time.
0 commit comments