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)
263
263
lvl_entry [i ] = ((rt_ubase_t * )aspace -> page_table + lvl_off [i ]);
264
264
pentry = lvl_entry [i ];
265
265
266
+ /* check if lvl_entry[0] is valid. if no, return 0 directly. */
267
+ if (!PTE_USED (* pentry ))
268
+ {
269
+ return 0 ;
270
+ }
271
+
266
272
/* find leaf page table entry */
267
273
while (PTE_USED (* pentry ) && !PAGE_IS_LEAF (* pentry ))
268
274
{
269
275
i += 1 ;
276
+
277
+ if (i >= 3 )
278
+ {
279
+ unmapped = 0 ;
280
+ break ;
281
+ }
282
+
270
283
lvl_entry [i ] = ((rt_ubase_t * )PPN_TO_VPN (GET_PADDR (* pentry ), PV_OFFSET ) +
271
284
lvl_off [i ]);
272
285
pentry = lvl_entry [i ];
@@ -278,6 +291,10 @@ static size_t _unmap_area(struct rt_aspace *aspace, void *v_addr)
278
291
{
279
292
_unmap_pte (pentry , lvl_entry , i );
280
293
}
294
+ else
295
+ {
296
+ unmapped = 0 ; /* invalid pte, return 0. */
297
+ }
281
298
282
299
return unmapped ;
283
300
}
You can’t perform that action at this time.
0 commit comments