From nobody Tue Jun 27 03:38:30 2023 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Qqr5y4Glwz4jr4Y; Tue, 27 Jun 2023 03:38:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Qqr5y3p20z3MDN; Tue, 27 Jun 2023 03:38:30 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1687837110; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=iYolLzIQQJo6PIb2ZBcFQwrks4up9Gwe5PkGJ0nKn94=; b=eadzVybGMjP4kSnBnU2fb0ZJI/0zRFxvqfFJTHH7Na08aGEvb3sK+R1T9feiHBAs8ZMM03 aIYUAq+QGBd+3TcojQMmzEdHdLhUw34C2rJDii8WCynKpkjb4rVRb+5R4x6DKRODSeaVOa qgVbS33aPUwhem1DysRpeqhO2mazT2eMNO2qfqWAuqWFBt0oFwSrOWY3bdokYzar1WqA8S 19Z96Y1tEEFmBRqafJF4C84/7xHW8BHTgtUSzsTTrIdOcL6mSZOMDpGxWGrQye7qBkrVQP e3QBzKfTcuqNoUQQ9/OneIdNOkOlCEPbsZOY7BA1kz0XOLi05loKBL5kHjl+Ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1687837110; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=iYolLzIQQJo6PIb2ZBcFQwrks4up9Gwe5PkGJ0nKn94=; b=jUKG1LB+xsPzsdBffyWY8WDpg5hucJQGHvbRIKm00pjS0obhlCqJrvPvAHYgy2zB/Z5vDI cVK9IKzlF3+2wKQ1Hj76kBSq5fG0brq1CUivgqmQsz7YFkEYQK/RekwvJ+Iqx5HUSQjQc1 DWW4E6qJ/UP2JX0VKxriRYMiIKaM6jmOCUmOY/QrUPt7lQCaX53PSu8QtG5nDleDNzjEy6 sbo9yKCKY3S+XN2925BLmpl3xRwjCcIg9T8wb7ZskOa1UcsCPxdbcU4ABwSu/jINv5TTFG 0YNKUtlUkhZ/hHqZ+sOKhM75DWPZ/rQLf2utXVDq/41Oxr3cWwPDjrnUVlGmgw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1687837110; a=rsa-sha256; cv=none; b=ptYBTQiuTUquSGNl4cJap/BPtG3ck4O3uD+N2EBmeQnBdX4WhhKOIkDT8zxd1J1GVkoPAn BOqX9UeCOkeKAid72vzKALXZUxZvQSamxIp1hGg6cfvdlbpIuaVJEsejwndpBQHluCmRF1 CQEfvG4eQwVtWkhrZq6xPvtOmC8edyvkv/9+G4mX58zEWtHyI1KU4pDwEsqd3758AmFIsX za/s0KpoGmkTzQHUCDYfof0PpfnAKxyzezsWibWFrexqDFIYMcPhneb3Bn3XWZ2bZsP7xq NkOq8kigvxDbyUe1SAxxWHIDDHxxSkq783jVdtBun7KfWrAKZqfwsIr6nHBN0A== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Qqr5y2DjQzcWQ; Tue, 27 Jun 2023 03:38:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 35R3cUdE034540; Tue, 27 Jun 2023 03:38:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 35R3cUER034539; Tue, 27 Jun 2023 03:38:30 GMT (envelope-from git) Date: Tue, 27 Jun 2023 03:38:30 GMT Message-Id: <202306270338.35R3cUER034539@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: e932f0d2a3c3 - main - cam_xpt: Properly fail if a sim uses an unsupported transport. List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e932f0d2a3c3ccbdf6c72745a75488022662f80c Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=e932f0d2a3c3ccbdf6c72745a75488022662f80c commit e932f0d2a3c3ccbdf6c72745a75488022662f80c Author: John Baldwin AuthorDate: 2023-06-27 03:33:25 +0000 Commit: John Baldwin CommitDate: 2023-06-27 03:36:06 +0000 cam_xpt: Properly fail if a sim uses an unsupported transport. The default xport ops for a new bus is xport_default, not NULL, so check for that when determining if a bus failed to find a suitable transport. In addition, the path needs to be freed with xpt_free_path instead of a plain free so that the path's reference on the sim is dropped; otherwise, cam_sim_free in the caller after xpt_bus_register returns failure will hang forever. Note that we have to exempt the xpt bus from this check as it uses xport_default on purpose. Reviewed by: mav, imp Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D40617 --- sys/cam/cam_xpt.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/sys/cam/cam_xpt.c b/sys/cam/cam_xpt.c index 7bca42cb553e..9eb42a8f9141 100644 --- a/sys/cam/cam_xpt.c +++ b/sys/cam/cam_xpt.c @@ -4018,7 +4018,14 @@ xpt_bus_register(struct cam_sim *sim, device_t parent, uint32_t bus) xpt_path_inq(&cpi, path); - if (cam_ccb_success((union ccb *)&cpi)) { + /* + * Use the results of PATH_INQ to pick a transport. Note that + * the xpt bus (which uses XPORT_UNSPECIFIED) always uses + * xport_default instead of a transport from + * cam_xpt_port_set. + */ + if (cam_ccb_success((union ccb *)&cpi) && + cpi.transport != XPORT_UNSPECIFIED) { struct xpt_xport **xpt; SET_FOREACH(xpt, cam_xpt_xport_set) { @@ -4027,11 +4034,11 @@ xpt_bus_register(struct cam_sim *sim, device_t parent, uint32_t bus) break; } } - if (new_bus->xport == NULL) { + if (new_bus->xport == &xport_default) { xpt_print(path, "No transport found for %d\n", cpi.transport); xpt_release_bus(new_bus); - free(path, M_CAMXPT); + xpt_free_path(path); return (EINVAL); } }