All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH][-next] block, bfq: don't dereference bic before null checking it
@ 2017-04-20 14:07 ` Colin King
  0 siblings, 0 replies; 4+ messages in thread
From: Colin King @ 2017-04-20 14:07 UTC (permalink / raw)
  To: Paolo Valente, Jens Axboe, linux-block; +Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

The call to bfq_check_ioprio_change will dereference bic, however,
the null check for bic is after this call.  Move the the null
check on bic to before the call to avoid any potential null
pointer dereference issues.

Detected by CoverityScan, CID#1430138 ("Dereference before null check")

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 block/bfq-iosched.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c
index 6d14f18c0d45..bd8499ef157c 100644
--- a/block/bfq-iosched.c
+++ b/block/bfq-iosched.c
@@ -4401,11 +4401,11 @@ static int bfq_get_rq_private(struct request_queue *q, struct request *rq,
 
 	spin_lock_irq(&bfqd->lock);
 
-	bfq_check_ioprio_change(bic, bio);
-
 	if (!bic)
 		goto queue_fail;
 
+	bfq_check_ioprio_change(bic, bio);
+
 	bfq_bic_update_cgroup(bic, bio);
 
 	bfqq = bfq_get_bfqq_handle_split(bfqd, bic, bio, false, is_sync,
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH][-next] block, bfq: don't dereference bic before null checking it
@ 2017-04-20 14:07 ` Colin King
  0 siblings, 0 replies; 4+ messages in thread
From: Colin King @ 2017-04-20 14:07 UTC (permalink / raw)
  To: Paolo Valente, Jens Axboe, linux-block; +Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

The call to bfq_check_ioprio_change will dereference bic, however,
the null check for bic is after this call.  Move the the null
check on bic to before the call to avoid any potential null
pointer dereference issues.

Detected by CoverityScan, CID#1430138 ("Dereference before null check")

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 block/bfq-iosched.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c
index 6d14f18c0d45..bd8499ef157c 100644
--- a/block/bfq-iosched.c
+++ b/block/bfq-iosched.c
@@ -4401,11 +4401,11 @@ static int bfq_get_rq_private(struct request_queue *q, struct request *rq,
 
 	spin_lock_irq(&bfqd->lock);
 
-	bfq_check_ioprio_change(bic, bio);
-
 	if (!bic)
 		goto queue_fail;
 
+	bfq_check_ioprio_change(bic, bio);
+
 	bfq_bic_update_cgroup(bic, bio);
 
 	bfqq = bfq_get_bfqq_handle_split(bfqd, bic, bio, false, is_sync,
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH][-next] block, bfq: don't dereference bic before null checking it
  2017-04-20 14:07 ` Colin King
@ 2017-04-20 14:19   ` Jens Axboe
  -1 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2017-04-20 14:19 UTC (permalink / raw)
  To: Colin King; +Cc: Paolo Valente, linux-block, kernel-janitors, linux-kernel

On Thu, Apr 20 2017, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> The call to bfq_check_ioprio_change will dereference bic, however,
> the null check for bic is after this call.  Move the the null
> check on bic to before the call to avoid any potential null
> pointer dereference issues.

Thanks, added.

-- 
Jens Axboe

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH][-next] block, bfq: don't dereference bic before null checking it
@ 2017-04-20 14:19   ` Jens Axboe
  0 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2017-04-20 14:19 UTC (permalink / raw)
  To: Colin King; +Cc: Paolo Valente, linux-block, kernel-janitors, linux-kernel

On Thu, Apr 20 2017, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> The call to bfq_check_ioprio_change will dereference bic, however,
> the null check for bic is after this call.  Move the the null
> check on bic to before the call to avoid any potential null
> pointer dereference issues.

Thanks, added.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-04-20 14:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-20 14:07 [PATCH][-next] block, bfq: don't dereference bic before null checking it Colin King
2017-04-20 14:07 ` Colin King
2017-04-20 14:19 ` Jens Axboe
2017-04-20 14:19   ` Jens Axboe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.