From nobody Mon Jun 24 19:37:22 2024 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 4W7JBp4Xkxz5PWXf; Mon, 24 Jun 2024 19:37:22 +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 4W7JBp43LLz4rqG; Mon, 24 Jun 2024 19:37:22 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1719257842; 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=mUNN3z1tfRv3rjrLXccRierg/u7BwrwYGajLv3svJy4=; b=oIAZ7CYc+OIwFI7qABqzy6js14xZAQH9xq78FbZzuU6l3RFRjmM83WhyDe7hZisprHLdLF LYADmqSgkS4+J3rUE6tX8VmQaiLNlKVRWufBefn/6RnxVC9DwVPurQg8FOCOBvGD4/ZDo6 y2ztO3VXlgndczsMDh+vSYGTJxDkSfFl71SXXwBfLGNl9yFTZ7JsSjta6yAvisjkeFhVrX 1eYtHItakncGJLrqwJvGhY/ouf5Rd0V1nf8hvc3L2kok8ll+HY6lk80fn5yt2CVjFYncKf pNSnM6qTq5YDA2g+bGIe5xcjA2ohlO3kZpr2ijNQanF6aFdQ4ct3v6V30Bfi4Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1719257842; a=rsa-sha256; cv=none; b=ewcSThivekhjWpEiZ7IJksv7irCvAq9I1aUiWPPdnlraOY5nlGmbpNyfmKh5mvgTZ6L2+Q H7zt0yPYv7P/tpYVUv88rwzOPHrSvtA0LjfgE1MT5Fo/CXLViRQaDD6+Oa4qNeTsrsQgYK 66EGHXRLf4lSpvI9Z1QLFwooslE9kPyuFR1JHGH5wlA3Ot2g3LYozDrPHTZzN5TWy1lQZD llY1AsVzwbUmRjQYnx/iQ6ia84a4dp/q6J/4QM0upQalGdrLXT6Ueji8x9wkH3fTeb00vS Nr7PdLjK58r4iilJWKf7pNycvGrlwNI4btUWnTpoPeZyG9xfdweiLEonntmPbg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1719257842; 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=mUNN3z1tfRv3rjrLXccRierg/u7BwrwYGajLv3svJy4=; b=Wb+fO8K9bAgaQhlJMEnFhJbJQt+Njw+yaF6y086E2aIy9iRS4J93kx/FPf6h441ijREHkh MJ+WyOCZs0mFpXqS6Hmi0nqZn7HPY/VxOyrtXzEUcRuP9swjZp06Sw1XguJJb8FY/tO6Hr JGgJ4p6cwUW6UhYCwaoSNtiWCiS3AdZq/p35PEOEfNmwZaTHmKMckza6ipWTj9OWGFYfkL CNmcoMbC+XQVEQLbrt7aH0VQOmJAag7C2yEt++XZKGdybsq0w/qppMstmzOgDrXTnyhr+3 dqRsC4/OaDrp7ufxdO0Z33mavkgw4cjH6r9NU05SxnJkT3QF+cxA3SMINzudag== 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 4W7JBp3fJxzWTG; Mon, 24 Jun 2024 19:37:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 45OJbMsc081505; Mon, 24 Jun 2024 19:37:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 45OJbMup081502; Mon, 24 Jun 2024 19:37:22 GMT (envelope-from git) Date: Mon, 24 Jun 2024 19:37:22 GMT Message-Id: <202406241937.45OJbMup081502@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ed Maste Subject: git: 1efd69f933b6 - main - p9fs: move NULL check immediately after allocation 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 1efd69f933b6ad4177ecda78cf4891aa9a1e8f6b Auto-Submitted: auto-generated The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=1efd69f933b6ad4177ecda78cf4891aa9a1e8f6b commit 1efd69f933b6ad4177ecda78cf4891aa9a1e8f6b Author: Ed Maste AuthorDate: 2024-06-24 16:21:19 +0000 Commit: Ed Maste CommitDate: 2024-06-24 19:36:11 +0000 p9fs: move NULL check immediately after allocation Reported by: Shawn Webb (HardenedBSD) Reviewed by: dfr Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D45719 --- sys/dev/virtio/p9fs/virtio_p9fs.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/sys/dev/virtio/p9fs/virtio_p9fs.c b/sys/dev/virtio/p9fs/virtio_p9fs.c index 48430b4f6b67..811faff6cd93 100644 --- a/sys/dev/virtio/p9fs/virtio_p9fs.c +++ b/sys/dev/virtio/p9fs/virtio_p9fs.c @@ -332,6 +332,11 @@ vt9p_attach(device_t dev) cv_init(&chan->submit_cv, "Conditional variable for submit queue" ); chan->max_nsegs = MAX_SUPPORTED_SGS; chan->vt9p_sglist = sglist_alloc(chan->max_nsegs, M_NOWAIT); + if (chan->vt9p_sglist == NULL) { + error = ENOMEM; + P9_DEBUG(ERROR, "%s: Cannot allocate sglist\n", __func__); + goto out; + } /* Negotiate the features from the host */ virtio_set_feature_desc(dev, virtio_9p_feature_desc); @@ -367,12 +372,6 @@ vt9p_attach(device_t dev) SYSCTL_ADD_STRING(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "p9fs_mount_tag", CTLFLAG_RD, chan->mount_tag, 0, "Mount tag"); - if (chan->vt9p_sglist == NULL) { - error = ENOMEM; - P9_DEBUG(ERROR, "%s: Cannot allocate sglist\n", __func__); - goto out; - } - /* We expect one virtqueue, for requests. */ error = vt9p_alloc_virtqueue(chan);