Skip to content

Commit

Permalink
nvmet-tcp: fix uninitialized variable access
Browse files Browse the repository at this point in the history
If we end up in nvmet_tcp_try_recv_one with a bogus state
queue receive state we will access result which is uninitialized.

Initialize restult to 0 which will be considered as if no data
was received by the tcp socket.

Fixes: 872d26a ("nvmet-tcp: add NVMe over TCP target driver")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Sagi Grimberg authored and Jens Axboe committed Jan 16, 2019
1 parent 7809167 commit fb86585
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/nvme/target/tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1089,7 +1089,7 @@ static int nvmet_tcp_try_recv_ddgst(struct nvmet_tcp_queue *queue)

static int nvmet_tcp_try_recv_one(struct nvmet_tcp_queue *queue)
{
int result;
int result = 0;

if (unlikely(queue->rcv_state == NVMET_TCP_RECV_ERR))
return 0;
Expand Down

0 comments on commit fb86585

Please sign in to comment.