Skip to content

Commit 1441779

Browse files
namhyungJens Axboe
authored andcommitted
block: fix an address space warning in blk-map.c
Change type of 2nd parameter of blk_rq_aligned() into unsigned long and remove unnecessary casting. Now we can call it with 'uaddr' instead of 'ubuf' in __blk_rq_map_user() so that it can remove following warnings from sparse: block/blk-map.c:57:31: warning: incorrect type in argument 2 (different address spaces) block/blk-map.c:57:31: expected void *addr block/blk-map.c:57:31: got void [noderef] <asn:1>*ubuf However blk_rq_map_kern() needs one more local variable to handle it. Signed-off-by: Namhyung Kim <namhyung@gmail.com> Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
1 parent 8dcbdc7 commit 1441779

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

block/blk-map.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ static int __blk_rq_map_user(struct request_queue *q, struct request *rq,
5454
* direct dma. else, set up kernel bounce buffers
5555
*/
5656
uaddr = (unsigned long) ubuf;
57-
if (blk_rq_aligned(q, ubuf, len) && !map_data)
57+
if (blk_rq_aligned(q, uaddr, len) && !map_data)
5858
bio = bio_map_user(q, NULL, uaddr, len, reading, gfp_mask);
5959
else
6060
bio = bio_copy_user(q, map_data, uaddr, len, reading, gfp_mask);
@@ -288,6 +288,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
288288
unsigned int len, gfp_t gfp_mask)
289289
{
290290
int reading = rq_data_dir(rq) == READ;
291+
unsigned long addr = (unsigned long) kbuf;
291292
int do_copy = 0;
292293
struct bio *bio;
293294
int ret;
@@ -297,7 +298,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
297298
if (!len || !kbuf)
298299
return -EINVAL;
299300

300-
do_copy = !blk_rq_aligned(q, kbuf, len) || object_is_on_stack(kbuf);
301+
do_copy = !blk_rq_aligned(q, addr, len) || object_is_on_stack(kbuf);
301302
if (do_copy)
302303
bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading);
303304
else

include/linux/blkdev.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,11 +1097,11 @@ static inline int queue_dma_alignment(struct request_queue *q)
10971097
return q ? q->dma_alignment : 511;
10981098
}
10991099

1100-
static inline int blk_rq_aligned(struct request_queue *q, void *addr,
1100+
static inline int blk_rq_aligned(struct request_queue *q, unsigned long addr,
11011101
unsigned int len)
11021102
{
11031103
unsigned int alignment = queue_dma_alignment(q) | q->dma_pad_mask;
1104-
return !((unsigned long)addr & alignment) && !(len & alignment);
1104+
return !(addr & alignment) && !(len & alignment);
11051105
}
11061106

11071107
/* assumes size > 256 */

0 commit comments

Comments
 (0)