bsg: fix potential error pointer dereference
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>
diff --git a/block/bsg.c b/block/bsg.c
index 73c78fd..276e869 100644
--- a/block/bsg.c
+++ b/block/bsg.c
@@ -287,6 +287,7 @@
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;