History

kthread: zero the kthread data structure

kthread() could bail out early before we initialize blkcg_css (if the kthread is killed very early. Please see xchg() statement in kthread()), which confuses free_kthread_struct. Instead of moving the blkcg_css initialization early, we simply zero the whole 'self' data structure, which doesn't sound much overhead.

Shaohua Li committed 9 years ago

Commit e10237c1 parent 18c53e41 file · +1 −5Browse files

Showing the changes to kernel/kthread.c (1 of 1 file). Show all

Unified · Split

kernel/kthread.c+1−5
@@ -204,7 +204,7 @@ static int kthread(void *_create) · 203 unmodified lines
204204 struct kthread *self;
205205 int ret;
206206
207− self = kmalloc(sizeof(*self), GFP_KERNEL);
207+ self = kzalloc(sizeof(*self), GFP_KERNEL);
208208 set_kthread_struct(self);
209209
210210 /* If user was SIGKILLed, I release the structure. */
@@ -220,13 +220,9 @@ static int kthread(void *_create) · 9 unmodified lines
220220 do_exit(-ENOMEM);
221221 }
222222
223− self->flags = 0;
224223 self->data = data;
225224 init_completion(&self->exited);
226225 init_completion(&self->parked);
227−#ifdef CONFIG_BLK_CGROUP
228− self->blkcg_css = NULL;
229−#endif
230226 current->vfork_done = &self->exited;
231227
232228 /* OK, tell user we're spawned, wait for stop or wakeup */