aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaolo Valente <paolo.valente@linaro.org>2017-05-09 05:37:27 -0400
committerJens Axboe <axboe@fb.com>2017-05-10 09:39:43 -0400
commita66c38a171ed25488debf80247a9e72e1026e82c (patch)
tree52c407a83f2706d34e5ced556903bcb5939265dc
parentfba704b494fdc6816a039a66887274b4e5c00eeb (diff)
block, bfq: use pointer entity->sched_data only if set
In the function __bfq_deactivate_entity, the pointer entity->sched_data could happen to be used before being properly initialized. This led to a NULL pointer dereference. This commit fixes this bug by just using this pointer only where it is safe to do so. Reported-by: Tom Harrison <l12436.tw@gmail.com> Tested-by: Tom Harrison <l12436.tw@gmail.com> Signed-off-by: Paolo Valente <paolo.valente@linaro.org> Signed-off-by: Jens Axboe <axboe@fb.com>
-rw-r--r--block/bfq-wf2q.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/block/bfq-wf2q.c b/block/bfq-wf2q.c
index b4fc3e4260b7..8726ede19eef 100644
--- a/block/bfq-wf2q.c
+++ b/block/bfq-wf2q.c
@@ -1114,12 +1114,21 @@ static void bfq_activate_requeue_entity(struct bfq_entity *entity,
1114bool __bfq_deactivate_entity(struct bfq_entity *entity, bool ins_into_idle_tree) 1114bool __bfq_deactivate_entity(struct bfq_entity *entity, bool ins_into_idle_tree)
1115{ 1115{
1116 struct bfq_sched_data *sd = entity->sched_data; 1116 struct bfq_sched_data *sd = entity->sched_data;
1117 struct bfq_service_tree *st = bfq_entity_service_tree(entity); 1117 struct bfq_service_tree *st;
1118 int is_in_service = entity == sd->in_service_entity; 1118 bool is_in_service;
1119 1119
1120 if (!entity->on_st) /* entity never activated, or already inactive */ 1120 if (!entity->on_st) /* entity never activated, or already inactive */
1121 return false; 1121 return false;
1122 1122
1123 /*
1124 * If we get here, then entity is active, which implies that
1125 * bfq_group_set_parent has already been invoked for the group
1126 * represented by entity. Therefore, the field
1127 * entity->sched_data has been set, and we can safely use it.
1128 */
1129 st = bfq_entity_service_tree(entity);
1130 is_in_service = entity == sd->in_service_entity;
1131
1123 if (is_in_service) 1132 if (is_in_service)
1124 bfq_calc_finish(entity, entity->service); 1133 bfq_calc_finish(entity, entity->service);
1125 1134