Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f97d4f61 authored by Dolev Raviv's avatar Dolev Raviv
Browse files

block: prevent access to NULL pointer in req->part



Block layer is accessing req->part without checking for NULL
pointer access, it is done when statistcs is not fully
initialized. Preventing the NULL pointer access effects only
the statistics update.

Change-Id: I45c91c074ecec1c3849f4f36185edcc6db35383c
Signed-off-by: default avatarYaniv Gardi <ygardi@codeaurora.org>
Signed-off-by: default avatarDolev Raviv <draviv@codeaurora.org>
parent 128a50cf
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -2099,8 +2099,11 @@ static void blk_account_io_completion(struct request *req, unsigned int bytes)
		struct hd_struct *part;
		int cpu;

		cpu = part_stat_lock();
		part = req->part;
		if (!part)
			return;

		cpu = part_stat_lock();
		part_stat_add(cpu, part, sectors[rw], bytes >> 9);
		part_stat_unlock();
	}
@@ -2119,14 +2122,15 @@ static void blk_account_io_done(struct request *req)
		struct hd_struct *part;
		int cpu;

		cpu = part_stat_lock();
		part = req->part;
		if (!req->part)
			return;

		cpu = part_stat_lock();
		part_stat_inc(cpu, part, ios[rw]);
		part_stat_add(cpu, part, ticks[rw], duration);
		part_round_stats(cpu, part);
		part_dec_in_flight(part, rw);

		hd_struct_put(part);
		part_stat_unlock();
	}