From: Jens Axboe Date: Thu, 28 Aug 2014 21:05:40 +0000 (-0600) Subject: bsg: fix potential error pointer dereference X-Git-Tag: v4.14-rc1~6394^2~112 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=55872c5a3c01f0fe7b5298d19e24e237f5b5ff06;p=platform%2Fkernel%2Flinux-rpi.git 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 Signed-off-by: Jens Axboe --- 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 @@ 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;