From nobody Sat Jan 11 05:00:28 2025 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 4YVRDD5Frkz5lFrn; Sat, 11 Jan 2025 05:00:28 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4YVRDD27FYz4cMg; Sat, 11 Jan 2025 05:00:28 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1736571628; 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=k4gHc7lBLe+DoHZ3XMj8LyCnWvHqNt+H+ASCk4KQfyg=; b=u7LRBX/3J96Guv3lWGkmt26Fn2AK/1FZ2M443skEOuHJZ+EfCmoSqJr8qXqR05UIF5B7BQ v45iWQERdebWq5eGve0jBG0xD+zi1Zn+6rQdZALr4e0qjyHgt3p/GAfR8ErCQbLCdEkXOL bhNo2Am/uihcvb/y2o/J/XMOJUeYxIYuh0XOjekMCfCxNqFpstOb/rS58TVVS8cmEYyh/U 3AHgwGr22wmFsno8suIrfA5x4nDnTsbYbKYKYWsIg2GZ3h/Ccvwk8aazR028s9gBD6r5dw HGL2dMKZbWrO5wCdVG8Efnn45mOMrZGL3uXWklmd/1yq1MOb3L22dqZvcOL7tA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1736571628; 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=k4gHc7lBLe+DoHZ3XMj8LyCnWvHqNt+H+ASCk4KQfyg=; b=dky7zelC+Rb0MQYlWTYBXkLUOavbQ/MVZGuZV0lm31OyrdKEUsrapsaih0jqA9HM/Avz+M ij/DQWFmuxwdgVIZ1/PcrAjRS66se91NMYmSh0CmJnDmXrhAXo/P+8MPIufDbCXMVqcCIK Bvf3zslskEEgsGzKp49qSFdWfJ1285OSTj2+ViaVBh5xyw9TbDL8WXVbeZwyHn+wUVzdnR CHqIx79fYWbdBAwH7PEDcNFCD2cqSOEjnVcCrNEdz6Rb32O0CNuY37m8DSmyhhoCW6htlT KQGygLcKtzjohzJTQrd62TAvK8HUC8zHHhx9gpi2knHA6tY7z9vAV3WsuYrC9w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1736571628; a=rsa-sha256; cv=none; b=hsZzzKTquS62qzXErDwsmgSTpLeWtydk/fSdoYu5z0EAjg3RnnDDCmh/nyJrK6pgkzrM+f QDOFnE/dAmnklk5dRPS8ATPNIZl2dOwUMklCRrZeECc7XF+HSi1fn6G3dLdIAe+k0AGv7e N4ehXBGWeAo6rpLDRdEHxjpB3GM7rytNI0MAUiI5MBW5frrhMCdUnKRjkudbe9wwZsEOJf lzyFGOaKIUKQftcEjeWe5OZstQ4TgzmTlYSOGjqa2rIT8DejQ6DkPc1AdJ54zyGUukaHvp a5lutQn3LPy3b7VIdILryi6Np4Nf8rkDfTlD72YsNpvk+fhR4eIrrRKYhSwHRw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4YVRDD1gQHzkb4; Sat, 11 Jan 2025 05:00:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 50B50SFf022557; Sat, 11 Jan 2025 05:00:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 50B50SuK022554; Sat, 11 Jan 2025 05:00:28 GMT (envelope-from git) Date: Sat, 11 Jan 2025 05:00:28 GMT Message-Id: <202501110500.50B50SuK022554@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Smirnoff Subject: git: 26d1ad5a44e1 - main - netlink: snl_create_genl_msg_request() may fail due to ENOMEM 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: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: glebius X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 26d1ad5a44e17d2d8c48d36755567043349d8b63 Auto-Submitted: auto-generated The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=26d1ad5a44e17d2d8c48d36755567043349d8b63 commit 26d1ad5a44e17d2d8c48d36755567043349d8b63 Author: Gleb Smirnoff AuthorDate: 2025-01-11 04:58:08 +0000 Commit: Gleb Smirnoff CommitDate: 2025-01-11 04:58:08 +0000 netlink: snl_create_genl_msg_request() may fail due to ENOMEM Reviewed by: melifaro Differential Revision: https://reviews.freebsd.org/D48310 --- sys/netlink/netlink_snl_generic.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/sys/netlink/netlink_snl_generic.h b/sys/netlink/netlink_snl_generic.h index 32b460c612bd..e2dc4d1bfffe 100644 --- a/sys/netlink/netlink_snl_generic.h +++ b/sys/netlink/netlink_snl_generic.h @@ -33,16 +33,24 @@ /* Genetlink helpers */ static inline struct nlmsghdr * -snl_create_genl_msg_request(struct snl_writer *nw, int genl_family, uint8_t genl_cmd) +snl_create_genl_msg_request(struct snl_writer *nw, uint16_t genl_family, + uint8_t genl_cmd) { + struct nlmsghdr *hdr; + struct genlmsghdr *ghdr; + assert(nw->hdr == NULL); - struct nlmsghdr *hdr = snl_reserve_msg_object(nw, struct nlmsghdr); + hdr = snl_reserve_msg_object(nw, struct nlmsghdr); + if (__predict_false(hdr == NULL)) + return (NULL); hdr->nlmsg_type = genl_family; hdr->nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK; - nw->hdr = hdr; - struct genlmsghdr *ghdr = snl_reserve_msg_object(nw, struct genlmsghdr); + ghdr = snl_reserve_msg_object(nw, struct genlmsghdr); + if (__predict_false(ghdr == NULL)) + return (NULL); ghdr->cmd = genl_cmd; + nw->hdr = hdr; return (hdr); }