Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1355054 > unrolled thread

[PATCH] block: fix possible NULL dereference

Started bySudip Mukherjee <sudipm.mukherjee@gmail.com>
First post2016-03-10 12:40 +0100
Last post2016-03-10 16:50 +0100
Articles 3 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] block: fix possible NULL dereference Sudip Mukherjee <sudipm.mukherjee@gmail.com> - 2016-03-10 12:40 +0100
    Re: [PATCH] block: fix possible NULL dereference Johannes Thumshirn <jthumshirn@suse.de> - 2016-03-10 13:10 +0100
    Re: [PATCH] block: fix possible NULL dereference Jens Axboe <axboe@kernel.dk> - 2016-03-10 16:50 +0100

#1355054 — [PATCH] block: fix possible NULL dereference

FromSudip Mukherjee <sudipm.mukherjee@gmail.com>
Date2016-03-10 12:40 +0100
Subject[PATCH] block: fix possible NULL dereference
Message-ID<rb76G-6oK-21@gated-at.bofh.it>
We were checking for iter to be NULL after dereferencing it. Lets first
check it and then use it.

Signed-off-by: Sudip Mukherjee <sudip.mukherjee@codethink.co.uk>
---
 block/blk-map.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/block/blk-map.c b/block/blk-map.c
index a54f054..089ed59 100644
--- a/block/blk-map.c
+++ b/block/blk-map.c
@@ -126,7 +126,7 @@ int blk_rq_map_user_iov(struct request_queue *q, struct request *rq,
 			const struct iov_iter *iter, gfp_t gfp_mask)
 {
 	struct iovec iov, prv = {.iov_base = NULL, .iov_len = 0};
-	bool copy = (q->dma_pad_mask & iter->count) || map_data;
+	bool copy;
 	struct bio *bio = NULL;
 	struct iov_iter i;
 	int ret;
@@ -134,6 +134,7 @@ int blk_rq_map_user_iov(struct request_queue *q, struct request *rq,
 	if (!iter || !iter->count)
 		return -EINVAL;
 
+	copy = (q->dma_pad_mask & iter->count) || map_data;
 	iov_for_each(iov, i, *iter) {
 		unsigned long uaddr = (unsigned long) iov.iov_base;
 
-- 
1.9.1

[toc] | [next] | [standalone]


#1355068

FromJohannes Thumshirn <jthumshirn@suse.de>
Date2016-03-10 13:10 +0100
Message-ID<rb7zJ-6OQ-35@gated-at.bofh.it>
In reply to#1355054
On Thu, Mar 10, 2016 at 05:09:13PM +0530, Sudip Mukherjee wrote:
> We were checking for iter to be NULL after dereferencing it. Lets first
> check it and then use it.
> 
> Signed-off-by: Sudip Mukherjee <sudip.mukherjee@codethink.co.uk>

Good catch
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>

-- 
Johannes Thumshirn                                          Storage
jthumshirn@suse.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850

[toc] | [prev] | [next] | [standalone]


#1355224

FromJens Axboe <axboe@kernel.dk>
Date2016-03-10 16:50 +0100
Message-ID<rbb0C-AW-9@gated-at.bofh.it>
In reply to#1355054
On 03/10/2016 04:39 AM, Sudip Mukherjee wrote:
> We were checking for iter to be NULL after dereferencing it. Lets first
> check it and then use it.

Nobody calls it with iter == NULL, I think we should just kill the !iter 
check


-- 
Jens Axboe

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web