linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Felipe Pena <felipensp@gmail.com>
To: Or Gerlitz <ogerlitz@mellanox.com>, Roi Dayan <roid@mellanox.com>,
	Roland Dreier <roland@kernel.org>,
	Sean Hefty <sean.hefty@intel.com>,
	Hal Rosenstock <hal.rosenstock@gmail.com>
Cc: linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org,
	Felipe Pena <felipensp@gmail.com>
Subject: [PATCH 1/1] drivers: infiniband: ulp: Fix possible use-after-free
Date: Sun, 13 Oct 2013 21:22:46 -0300	[thread overview]
Message-ID: <1381710166-27341-1-git-send-email-felipensp@gmail.com> (raw)

The tx_desc variable is being used to access its type member
after a kmem_cache_free call

Signed-off-by: Felipe Pena <felipensp@gmail.com>
---
 drivers/infiniband/ulp/iser/iser_initiator.c |    8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/infiniband/ulp/iser/iser_initiator.c b/drivers/infiniband/ulp/iser/iser_initiator.c
index 5388226..15b545c 100644
--- a/drivers/infiniband/ulp/iser/iser_initiator.c
+++ b/drivers/infiniband/ulp/iser/iser_initiator.c
@@ -610,17 +610,15 @@ void iser_snd_completion(struct iser_tx_desc *tx_desc,
 		ib_dma_unmap_single(device->ib_device, tx_desc->dma_addr,
 					ISER_HEADERS_LEN, DMA_TO_DEVICE);
 		kmem_cache_free(ig.desc_cache, tx_desc);
-	}
-
-	atomic_dec(&ib_conn->post_send_buf_count);
-
-	if (tx_desc->type == ISCSI_TX_CONTROL) {
+	} else if (tx_desc->type == ISCSI_TX_CONTROL) {
 		/* this arithmetic is legal by libiscsi dd_data allocation */
 		task = (void *) ((long)(void *)tx_desc -
 				  sizeof(struct iscsi_task));
 		if (task->hdr->itt == RESERVED_ITT)
 			iscsi_put_task(task);
 	}
+
+	atomic_dec(&ib_conn->post_send_buf_count);
 }
 
 void iser_task_rdma_init(struct iscsi_iser_task *iser_task)
-- 
1.7.10.4


                 reply	other threads:[~2013-10-14  0:22 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1381710166-27341-1-git-send-email-felipensp@gmail.com \
    --to=felipensp@gmail.com \
    --cc=hal.rosenstock@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=ogerlitz@mellanox.com \
    --cc=roid@mellanox.com \
    --cc=roland@kernel.org \
    --cc=sean.hefty@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).