From nobody Wed Mar 29 18:26:42 2023 X-Original-To: dev-commits-src-all@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 4Pmw4M0wdxz42v10; Wed, 29 Mar 2023 18:26:43 +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 4Pmw4M0JRVz3L96; Wed, 29 Mar 2023 18:26:43 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1680114403; 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=MEJ6ZzTsrnsM19aQn6PmOtiKaBtKrFYoux2bRpzfltc=; b=fQKcag63Tx/w51g9TTfTw12wgRIPZ7MYNvLrfAV1RLKHEoAXJir6VKXtALl0X88bFXkEUp YdJjFp8J4Fyf+SMUFXrhax9P94v2+VSqOLa31wbWs5MOOfwQuv9Xk+x71EbAWISUZHaxvT Wb0pnyo5z2/GK5PC5Tq2FZ6PeaQOalybZp9tIAzkYN8q4kZXKonnuPZS/2M/a0DA0/WrSK 8c59zCg4rHThxQFEnK39ubR7+iIg7MIBO/hrrXpjz3LeTqCLrORVoefz1hbECYrAFGRzgD q+4yFbk3MMNpGgqLbWMY9arOWKjmDnX3FWaYJAlDXOyN3hYnUqdvOy8YQQVUEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1680114403; 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=MEJ6ZzTsrnsM19aQn6PmOtiKaBtKrFYoux2bRpzfltc=; b=cPIUKMuX4a0Of9WArguUhBGNLg50i6UWXD6m5t9GE5r1RYUdiHY6eoWbtGEp34bMMqPbBn KQRo6JmSnlysAoEfqRs2LY0WvM1c7wob9CvyanQrz5YAdVCHcGHm9D6AWMERhJz3McITuD 5+UavSPrZiPngMvhLrwNwholKQfw/SHEH04md01zXJBhuJ4uw5ezcPst0BjQnhtWeRSOjh stSNiwwFOrestLsZVlc09vqvhSa2+YRcX7sa000qwaLBKEyOpyAkWlF9GV3Nxb1Q+fc94J GR8NGKgP4wI+iA8iVpsXyyRDHU4cumim37NgotKk6kPlDQTpuEXGpqeCukDDig== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1680114403; a=rsa-sha256; cv=none; b=aQ4E1zE3gldfut/wtDsfj0/dyAlMKMhbIPehmperYNu9GzLbUpVf8bieJHb/VUNX6ai150 7IILfCX7nQXlLy9qhEuSfkHcqIcZBaJVjdTDxAO3Dy12h/xhZlSZtkNT/9u7Cd87AFYZMz sZWy8Ht/GP19dzRyKKZaAKivmMHr5CAR1Kb5oj58zwFpkgJwbhzDfd4debONKMEQv2u9lC rFfJ+eXQkaRyns7RMtQNqgZytqULZ2hYQXXcs7ZegmJG2mj1Sl4WnF4/m4+Y+ggrRmMBOg x5E/IHK6JKD4X0XZBQgMIJpdwz48EuKHDyppZn3CplNIKEMeh+kMU2SVz1j84w== 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 4Pmw4L6RM1zgXW; Wed, 29 Mar 2023 18:26:42 +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 32TIQgbV089060; Wed, 29 Mar 2023 18:26:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 32TIQgYH089059; Wed, 29 Mar 2023 18:26:42 GMT (envelope-from git) Date: Wed, 29 Mar 2023 18:26:42 GMT Message-Id: <202303291826.32TIQgYH089059@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Eric van Gyzen Subject: git: 3bbd1a1a0056 - main - camcontrol powermode: fix use-after-free List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: vangyzen X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3bbd1a1a005698fcf1aaeae0065a8f2f97fdf4be Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by vangyzen: URL: https://cgit.FreeBSD.org/src/commit/?id=3bbd1a1a005698fcf1aaeae0065a8f2f97fdf4be commit 3bbd1a1a005698fcf1aaeae0065a8f2f97fdf4be Author: Eric van Gyzen AuthorDate: 2023-03-29 19:14:40 +0000 Commit: Eric van Gyzen CommitDate: 2023-03-29 19:17:16 +0000 camcontrol powermode: fix use-after-free Free the ccb after processing the response therein. Reported by: Coverity Fixes: 3bed0179ee571ba3ceadb2773f86d57af8bc5499 MFC after: 1 week Sponsored by: Dell EMC Isilon --- sbin/camcontrol/camcontrol.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/sbin/camcontrol/camcontrol.c b/sbin/camcontrol/camcontrol.c index 489c3026537a..9e50fbf2646e 100644 --- a/sbin/camcontrol/camcontrol.c +++ b/sbin/camcontrol/camcontrol.c @@ -9312,12 +9312,11 @@ atapm(struct cam_device *device, int argc, char **argv, /*timeout*/timeout ? timeout : 30 * 1000, /*force48bit*/0); - cam_freeccb(ccb); - - if (retval || cmd != ATA_CHECK_POWER_MODE) - return (retval); + if (retval == 0 && cmd == ATA_CHECK_POWER_MODE) + retval = atapm_proc_resp(device, ccb); - return (atapm_proc_resp(device, ccb)); + cam_freeccb(ccb); + return (retval); } static int