Skip to content

Commit

Permalink
drbd: fix NULL pointer deref in blk_add_request_payload
Browse files Browse the repository at this point in the history
Discards don't have any payload.
But the scsi layer still expects a bio_vec it can use internally,
see sd_setup_discard_cmnd() and blk_add_request_payload().

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
  • Loading branch information
Lars Ellenberg authored and Jens Axboe committed Jun 25, 2014
1 parent 0ffbce8 commit 54ed4ed
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/block/drbd/drbd_receiver.c
Original file line number Diff line number Diff line change
Expand Up @@ -1337,8 +1337,11 @@ int drbd_submit_peer_request(struct drbd_device *device,
return 0;
}

/* Discards don't have any payload.
* But the scsi layer still expects a bio_vec it can use internally,
* see sd_setup_discard_cmnd() and blk_add_request_payload(). */
if (peer_req->flags & EE_IS_TRIM)
nr_pages = 0; /* discards don't have any payload. */
nr_pages = 1;

/* In most cases, we will only need one bio. But in case the lower
* level restrictions happen to be different at this offset on this
Expand Down

0 comments on commit 54ed4ed

Please sign in to comment.