Commit 4f47c066 authored by Ziye Yang's avatar Ziye Yang Committed by Changpeng Liu
Browse files

iscsi initiator: remove the deleted variable.



I do not think that this variable is needed.
The rpc system will be always executed in the first
call, so there is no sync issue, add a deleted variable
and put the free in the loop sounds not very clear.

For the ASAN issue (use req after free), I think
that the correct solution is that: we should store
the context first instead of defer the free of req.

Change-Id: I49ca2708ddc2c5533bb3a0aee4622ae23bfe47c6
Signed-off-by: default avatarZiye Yang <optimistyzy@gmail.com>
Reviewed-on: https://review.gerrithub.io/414726


Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
parent 7efc7b83
Loading
Loading
Loading
Loading
+7 −10
Original line number Diff line number Diff line
@@ -100,7 +100,6 @@ struct bdev_iscsi_conn_req {
	spdk_bdev_iscsi_create_cb		create_cb;
	spdk_bdev_iscsi_create_cb		create_cb_arg;
	TAILQ_ENTRY(bdev_iscsi_conn_req)	link;
	bool					deleted;
};

static int
@@ -537,7 +536,7 @@ complete_conn_req(struct bdev_iscsi_conn_req *req, struct spdk_bdev *bdev,
{
	TAILQ_REMOVE(&g_iscsi_conn_req, req, link);
	req->create_cb(req->create_cb_arg, bdev, status);
	req->deleted = true;
	free(req);
}

static int
@@ -646,10 +645,12 @@ iscsi_bdev_conn_poll(void *arg)
{
	struct bdev_iscsi_conn_req *req, *tmp;
	struct pollfd pfd;
	struct iscsi_context *context;

	TAILQ_FOREACH_SAFE(req, &g_iscsi_conn_req, link, tmp) {
		pfd.fd = iscsi_get_fd(req->context);
		pfd.events = iscsi_which_events(req->context);
		context = req->context;
		pfd.fd = iscsi_get_fd(context);
		pfd.events = iscsi_which_events(context);
		pfd.revents = 0;
		if (poll(&pfd, 1, 0) < 0) {
			SPDK_ERRLOG("poll failed\n");
@@ -657,13 +658,9 @@ iscsi_bdev_conn_poll(void *arg)
		}

		if (pfd.revents != 0) {
			if (iscsi_service(req->context, pfd.revents) < 0) {
				SPDK_ERRLOG("iscsi_service failed: %s\n", iscsi_get_error(req->context));
			}
			if (iscsi_service(context, pfd.revents) < 0) {
				SPDK_ERRLOG("iscsi_service failed: %s\n", iscsi_get_error(context));
			}

		if (req->deleted) {
			free(req);
		}
	}