]> git.baikalelectronics.ru Git - kernel.git/commitdiff
bsg: fix potential error pointer dereference
authorJens Axboe <axboe@fb.com>
Thu, 28 Aug 2014 21:05:40 +0000 (15:05 -0600)
committerJens Axboe <axboe@fb.com>
Fri, 29 Aug 2014 14:34:14 +0000 (08:34 -0600)
Dan writes:

block/bsg.c:327 bsg_map_hdr() error: 'next_rq' dereferencing possible
ERR_PTR().

Fix this by setting next_rq to NULL, for the case where it can be
!= NULL but an error pointer.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
block/bsg.c

index 73c78fd12cc1c8dc33b4ee3cc560c8f2d811a04a..276e869e686cbbdb39112f19b163e353f0ddc3ef 100644 (file)
@@ -287,6 +287,7 @@ bsg_map_hdr(struct bsg_device *bd, struct sg_io_v4 *hdr, fmode_t has_write_perm,
                next_rq = blk_get_request(q, READ, GFP_KERNEL);
                if (IS_ERR(next_rq)) {
                        ret = PTR_ERR(next_rq);
+                       next_rq = NULL;
                        goto out;
                }
                rq->next_rq = next_rq;