From nobody Thu Apr 07 00:31:09 2022 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 690111A956AF; Thu, 7 Apr 2022 00:31:10 +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 4KYj3d5jH6z4sth; Thu, 7 Apr 2022 00:31:09 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1649291469; 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=ZwyRK1zZttvv1qUP59uvGZm+2Wu3lLlP/Br1uRGSYOQ=; b=wTtRW8pW0gqz4B7WDxJa8wWU5pLSNVOybqPtUncQqElZOWC14/9ruGkakj8Hd6nEIDsJzt p8qXYBufI16HdcnH5F4o4AHIg6OzUqjrG24LqezpPZ6A6OF0ecGZOA7TOnlEFmAGlr/hcm e9t2iSiXwchk//IC9nC86oxeeZT3yTonr7VsqQFNhgm9XrcS5hXa8ktP+oEUw7DQ+MC+c7 Jctlr7jB5O+W5gNv/acohMQQxqdFwTTPXdn54pPdF8b5jEPJt8abLrlXErofBOogOg7v7c 27Tlu5BdZs7ZT/8IIox2JnFWQLunoUHCxQ3ETlZpiF1naMerb62+i/apXLBPIQ== 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 4860C2557E; Thu, 7 Apr 2022 00:31:09 +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 2370V9dW073934; Thu, 7 Apr 2022 00:31:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2370V9Lh073933; Thu, 7 Apr 2022 00:31:09 GMT (envelope-from git) Date: Thu, 7 Apr 2022 00:31:09 GMT Message-Id: <202204070031.2370V9Lh073933@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 110b8112e5eb - stable/13 - stge: fix null pointer dereference 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: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 110b8112e5ebf2ba0f00479da1b7eafa83684d2e Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1649291469; 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=ZwyRK1zZttvv1qUP59uvGZm+2Wu3lLlP/Br1uRGSYOQ=; b=JcecTlOeJtvFWGIziboWrQMtL63xKZhozhwzyYYM81y7GN435ZlkuWVasRPPflT2pELpEG kD3uFJWgyfZyBibbP1TCUVNh8NmeRWbVdjv4Ag0ef6m+t5sSr+OwAtV7G3+h/D9UzE3grb Dz3lEXBY/uAXwmzq1PqGU7JjPcZd217FmuGybwI+2uaHbRHWBBRz6mbnMyxwc0ZtE0WZk5 2yNis5odvVUiDIujfoqp+Q4lc4ErGvHAzG3wVEja2w8yMqvDsvySBqS+CePkgrwoZEbMBR kWSZT9UzrfCaEQA/jTBBqqW7gRQXgTumUvciW5SQfNJ0OmA30TJQeXRbx2dJ8w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1649291469; a=rsa-sha256; cv=none; b=oByHve50gV6KOvnN0sm+/3n5qq7XSMdAURgMPcN8F33FumFdIiYtFpBS5xQD8tJwORkjYZ Pz5bBVvpmBuVD97735xAaxuBVDTlMvKKLwC5RbSUYdmGaD+9ItnawSc5O+Oh9QW8+Yp6oo KbkNxedm839wLbW0knxHBs1E1bcmuQYJZXmgO9vD3PoH3q9eTkAASME7bv9ZxMF1iMCxHV 8w0Di7n/hJShvJbnn/+PWWvLMgiH435kfHztgDSKMgMvi4hWnuCZDYAgJ7gSUzYzvNcbZR /Uu7HKRS5acdEEeNrm9JQlm0DMunFl4oF99HQ3pnMElqVOCncAw53MMBlemdzw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=110b8112e5ebf2ba0f00479da1b7eafa83684d2e commit 110b8112e5ebf2ba0f00479da1b7eafa83684d2e Author: Tong Zhang AuthorDate: 2022-03-31 18:16:55 +0000 Commit: Mark Johnston CommitDate: 2022-04-07 00:30:45 +0000 stge: fix null pointer dereference stge_attach() could fail at line 464, sc->sc_spec remains NULL when calling stge_detach(), thus bus_release_resources() at line 704 will trigger null pointer dereference. We need to check the nulliness before calling bus_release_resources(). PR: 258420 Reviewed by: markj (cherry picked from commit 2108cc72906f274f30306570268434c4f8d23636) --- sys/dev/stge/if_stge.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sys/dev/stge/if_stge.c b/sys/dev/stge/if_stge.c index c9f71f01278c..a043ca9a6e80 100644 --- a/sys/dev/stge/if_stge.c +++ b/sys/dev/stge/if_stge.c @@ -699,7 +699,9 @@ stge_detach(device_t dev) bus_teardown_intr(dev, sc->sc_res[1], sc->sc_ih); sc->sc_ih = NULL; } - bus_release_resources(dev, sc->sc_spec, sc->sc_res); + + if (sc->sc_spec) + bus_release_resources(dev, sc->sc_spec, sc->sc_res); mtx_destroy(&sc->sc_mii_mtx); mtx_destroy(&sc->sc_mtx);