Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 49115ac in mainline


Ignore:
Timestamp:
2017-08-19T11:03:47Z (3 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
master
Children:
e7ac23d
Parents:
e7c4115d
Message:

Add tsk_destructor() to free task's kobject

Freeing up kobject in task_destroy() leads to a kernel panic the next time the
task object is reused from the slab cache.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/proc/task.c

    re7c4115d r49115ac  
    8484static void task_kill_internal(task_t *);
    8585static int tsk_constructor(void *, unsigned int);
     86static size_t tsk_destructor(void *obj);
    8687
    8788/** Initialize kernel tasks support.
     
    9394        avltree_create(&tasks_tree);
    9495        task_slab = slab_cache_create("task_t", sizeof(task_t), 0,
    95             tsk_constructor, NULL, 0);
     96            tsk_constructor, tsk_destructor, 0);
    9697}
    9798
     
    167168       
    168169        list_initialize(&task->threads);
    169        
     170
    170171        task->kobject = malloc(sizeof(kobject_t) * MAX_KERNEL_OBJECTS, 0);
    171172       
     
    182183#endif
    183184       
     185        return 0;
     186}
     187
     188size_t tsk_destructor(void *obj)
     189{
     190        task_t *task = (task_t *) obj;
     191       
     192        free(task->kobject);
    184193        return 0;
    185194}
     
    285294        as_release(task->as);
    286295       
    287         free(task->kobject);
    288 
    289296        slab_free(task_slab, task);
    290297}
Note: See TracChangeset for help on using the changeset viewer.