From nobody Mon Nov 09 19:14:14 2026 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 4jNfbW10wzz70LLl for ; Mon, 09 Nov 2026 19:14:15 +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) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jNfbV6tbFz4TWR for ; Mon, 09 Nov 2026 19:14:14 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794251655; 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=8FobJv5HYI0wSK56IArb0uV4f8X7cv0ER38k8d/OZbs=; b=JHQbZfUF82xDoRSRnVaahx7NaqVK8/yhN2h2OiBiEEz94BJPX1QIVrY9zNYBQTApRFx8+i EjmOISlec0buBfgo0v8J1DmLkf0abTk6V9mXp+U7Adgw1BGrs70NrLBr69QR6/UCgBxAQA MUhGnaY/EnE9hn1YKhrhTu/1BeNtLLWOH4wIk3T5XVeB5kbcSGRWzd12SFHlpSVxdgU+zf CONyU9y7KhBIpoxB9QmrzuOEK8rGaxhZqJs9pgZStoDXWH8hiqkV2iyThcff3cQxrDq3uE iIv+9uHZ9PLvYPyDHIiUZPHIBLScjD5zgg7PtNePzKvs5Xl632IMYd1jHTYq9w== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794251655; b=Ra6tsXH1D3mgUYHjmKKUTl7HMNRG5Y9koKBAykd3bxSvol7r66jLuN/ubhaOiG9Uf9MCa8 FENrwjYGFeV8vJsyz75fIyGrGPy2WrzIsAWRF8yGntGrmpEWfjMXTuWuLBWcm3mEG3Aymw YV/uYzIXNmjTiN750koIBniWKjkHvRjNtSZiylF0QhfYZz97lDmaZvLBiM92Q5VnmVrnXH kEr0h6VM8Ku8oZ0Jk82jtpMMb7JNqweSk1CW7ip+1K5yBNCZAJpEwnvlAm4o6rBFO3oEtD nH1aysNRx3lSZZqei++vBSvxvSAaHt7/frQmQjAGvQ9MM1FXJmhw+aFo2LWY7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794251655; 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=8FobJv5HYI0wSK56IArb0uV4f8X7cv0ER38k8d/OZbs=; b=WgpJhnKryLLDgcIDJ1TX8xRpeqgH/cAcsQcxrCtu3rXyMnxgjL7w7ZKcDdvgjWsz5fVFAs 4XDXV+PS8yPbkaGkjEt0EtH+95gZT6SMUD8C0ImytpN/Az4HIXiKNTDNsD3jng8ItLImyW Q008rbGf80L6I+whzO8W7Uw0zyIECvkrQfEF8l8VnVqHFZ4odWczp7qWYPcMxAyPOwJ+y4 zKkdk5nFlDJAYzY86pf6kijZJT8/ei0jRzseWWQi0gockcHOGjLXwTL+S1UecbicOFtumX JwILHmJekmp83C7lqt44G52eIvHXF3vOuv06VcDEtspF/QSFDGmkw/PonYyO4w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jNfbV5zwJztjf for ; Mon, 09 Nov 2026 19:14:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id d641 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 09 Nov 2026 19:14:14 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kenneth D. Merry Subject: git: f7c24ef1e9a4 - main - camcontrol: Don't close the CAM device in nvme_get_data() List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org List-Id: Commit messages for the main branch of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: ken X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f7c24ef1e9a47b889eaaae8514c61e95d9738cf8 Auto-Submitted: auto-generated Date: Mon, 09 Nov 2026 19:14:14 +0000 Message-Id: <6af21b86.d641.6dbbf8c8@gitrepo.freebsd.org> The branch main has been updated by ken: URL: https://cgit.FreeBSD.org/src/commit/?id=f7c24ef1e9a47b889eaaae8514c61e95d9738cf8 commit f7c24ef1e9a47b889eaaae8514c61e95d9738cf8 Author: Kenneth D. Merry AuthorDate: 2026-11-09 18:47:01 +0000 Commit: Kenneth D. Merry CommitDate: 2026-11-09 18:59:13 +0000 camcontrol: Don't close the CAM device in nvme_get_data() nvme_get_data() closed the supplied CAM device on every error path, but its callers either pass the device that main() opened and closes, or close the device themselves, so an error resulted in a double cam_close_device() and a double free. Move the error path close into print_dev_nvme(), the one caller that opens its own device, and leave the device alone in nvme_get_data(). This predates the recent camcontrol NVMe additions, but they added more callers. Reported by: llm-postcr Fixes: 6ee13c54dad0 MFC after: 1 week Sponsored by: Spectra Logic Co-authored-by: Claude Fable 5 --- sbin/camcontrol/camcontrol.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sbin/camcontrol/camcontrol.c b/sbin/camcontrol/camcontrol.c index 28a2d39606a6..8a93206a3d7a 100644 --- a/sbin/camcontrol/camcontrol.c +++ b/sbin/camcontrol/camcontrol.c @@ -813,7 +813,6 @@ nvme_get_data(struct cam_device *dev, int nvme_data_type, void *data, ccb = cam_getccb(dev); if (ccb == NULL) { warnx("couldn't allocate CCB"); - cam_close_device(dev); return (1); } @@ -840,7 +839,6 @@ nvme_get_data(struct cam_device *dev, int nvme_data_type, void *data, return 0; bailout_error: - cam_close_device(dev); return (1); } @@ -858,8 +856,10 @@ print_dev_nvme(struct device_match_result *dev_result, char *tmpstr) return (1); } - if (nvme_get_data(dev, CDAI_TYPE_NVME_CNTRL, &cdata, sizeof(cdata))) + if (nvme_get_data(dev, CDAI_TYPE_NVME_CNTRL, &cdata, sizeof(cdata))) { + cam_close_device(dev); return (1); + } cam_strvis(vendor, cdata.mn, sizeof(cdata.mn), sizeof(vendor)); cam_strvis(product, cdata.fr, sizeof(cdata.fr), sizeof(product));