From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aib29ajc246.phx1.oracleemaildelivery.com (aib29ajc246.phx1.oracleemaildelivery.com [192.29.103.246]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1BBE6EB64D7 for ; Sat, 24 Jun 2023 02:54:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=oss-phx-1109; d=oss.oracle.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=XDZBSDyaA5pNR+c5xW+GGwShNBm8PqZnPMlCfNPaSGg=; b=isOG4/rAti46Mu5ymzvZTPSEEyjKPCc4IyIPRJ0fvX27g2KoSvd4p8pn0ZCBoMfscSFOg0//gBIs eVHnS2RJsGQ/s4/LMsPWxLhwzckw1wgg3iMEmJBM4y4haRCpuZWUWw9p2PNySS0PUZXh/pa5l/LR XeWEfzqS7DjK20iee8S8D5cgMj7slKwDXisj18mlaYwLhzkT30F9GSCTMiD8vSl/96DS//9CzXJZ hXM2rvHeyNLBwR3qoYubj0pBqsY2EnhF8+dZ3rDykFWeiYDspzsBU5bWQhXGAMGUu0qJW0/ub0fS Q7J7kaoshCsGEgqCVbq3uqnw5TgTWvvRWfz4VA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=prod-phx-20191217; d=phx1.rp.oracleemaildelivery.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=XDZBSDyaA5pNR+c5xW+GGwShNBm8PqZnPMlCfNPaSGg=; b=IIpr6uqrdISpFhcYkusG9ac9oHDKHXo44+ILU43cqDRn2M7mk30ZnoSpntSBcbPgHxLZ2mPHY3x3 l3/477GocQgwMbHHCHk+9YI+NPT0vou4RUOeD0x9RhgVrG8146DjTwtHTbAao+vxS1ZPVwhpLVgt kvyga0pwT7ti05B7mIfhVhe7Zq6tXiOwT+9T6f4Px4JJ+BY7vbSAgvPgp7T0ir2+qAobWqL19AKs q5Wl9itAkrLfqyWqd/Z0TIPs5DyrwjyJwl7Tek57c7w6bZp5spkBY4rrAQoxMp92P5ongwaO/xGa u1n6NVgB0JAUyzA7kCngZXeGK5Mg355zmUwALg== Received: by omta-ad1-fd3-101-us-phoenix-1.omtaad1.vcndpphx.oraclevcn.com (Oracle Communications Messaging Server 8.1.0.1.20230523 64bit (built May 23 2023)) with ESMTPS id <0RWQ00PBBLE56VA0@omta-ad1-fd3-101-us-phoenix-1.omtaad1.vcndpphx.oraclevcn.com> for ocfs2-devel@archiver.kernel.org; Sat, 24 Jun 2023 02:54:05 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687560958; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DznK2AUeRuZJq7eWmkzDsLOFPhbrN3vu6EuXAdMNepE=; b=I17uaVHxXDtllpyiVTtomGBUje2R31diHr4ASrXBHE1lWemlpfvHQPmHZu9/M+v1JGLqIE 1BWwoDFaQEbRLY++z1KaSfdE6cqHMjOCk8QC/56j5i7QKrzhqD9ULGVns9KoyvZQPCH/T2 H9TDQiYtygX9zNFfJAbMtITVCQGT/wk= To: netdev@vger.kernel.org Date: Fri, 23 Jun 2023 23:55:10 +0100 Message-id: <20230623225513.2732256-14-dhowells@redhat.com> In-reply-to: <20230623225513.2732256-1-dhowells@redhat.com> References: <20230623225513.2732256-1-dhowells@redhat.com> MIME-version: 1.0 X-Source-IP: 170.10.129.124 X-Proofpoint-Virus-Version: vendor=nai engine=6500 definitions=10750 signatures=596816 Cc: Jens Axboe , Willem de Bruijn , Kurt Hackel , David Ahern , linux-kernel@vger.kernel.org, Alexander Duyck , David Howells , linux-mm@kvack.org, Eric Dumazet , Jakub Kicinski , Paolo Abeni , "David S. Miller" , ocfs2-devel@oss.oracle.com Subject: [Ocfs2-devel] [PATCH net-next v5 13/16] ocfs2: Fix use of slab data with sendpage X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: David Howells via Ocfs2-devel Reply-to: David Howells Content-type: text/plain; charset="us-ascii" Content-transfer-encoding: 7bit Errors-to: ocfs2-devel-bounces@oss.oracle.com X-MC-Unique: scLXM6p0PSyn60UPmGbLlg-1 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Proofpoint-SPF-Result: pass X-Proofpoint-SPF-Record: v=spf1 ip4:107.21.15.141 ip4:108.177.8.0/21 ip4:128.17.0.0/20 ip4:128.17.128.0/20 ip4:128.17.192.0/20 ip4:128.17.64.0/20 ip4:128.245.0.0/20 ip4:128.245.64.0/20 ip4:13.110.208.0/21 ip4:13.110.216.0/22 ip4:13.110.224.0/20 ip4:13.111.0.0/16 ip4:136.147.128.0/20 ip4:136.147.176.0/20 ip4:148.105.8.0/21 ip4:149.72.0.0/16 ip4:159.183.0.0/16 include:spf1.redhat.com -all X-Proofpoint-SPF-VenPass: Allowed X-ServerName: us-smtp-delivery-124.mimecast.com X-Proofpoint-SPF-Result: pass X-Proofpoint-SPF-Record: v=spf1 ip4:107.21.15.141 ip4:108.177.8.0/21 ip4:128.17.0.0/20 ip4:128.17.128.0/20 ip4:128.17.192.0/20 ip4:128.17.64.0/20 ip4:128.245.0.0/20 ip4:128.245.64.0/20 ip4:13.110.208.0/21 ip4:13.110.216.0/22 ip4:13.110.224.0/20 ip4:13.111.0.0/16 ip4:136.147.128.0/20 ip4:136.147.176.0/20 ip4:148.105.8.0/21 ip4:149.72.0.0/16 ip4:159.183.0.0/16 include:spf1.redhat.com -all X-Proofpoint-Spam-Reason: safe X-Spam: OrgSafeList X-SpamRule: orgsafelist X-Proofpoint-ORIG-GUID: g2PiXrbgUOuJm93GH_msFnXuR-zdpk3E X-Proofpoint-GUID: g2PiXrbgUOuJm93GH_msFnXuR-zdpk3E Reporting-Meta: AAECKOCf44dwwvi5NidQGRQsmWgUdyEA0ayd9rXbwOhMQlklARYb3srYUIKUfHyE ddBAi47jQreF4jrm6Tut77dcZAPDBM4d3q04+c5xiblm8V/uH/lNQy+dw9TJf/Pc yQgIuFPj1W1BLZx2Qhlca8+pVGwJNbr/54EHT1pQjB2asHHen3lqr9MtWaH4GZcf 2G1krK7T71oMoCvSABcBo2TzpBnvPrqmKfaSQmIYqThvjcn6K8hHQ2Fx1wqYXw0H tnR3BZTluNsE/MjgGDq/zB89i2mAgTSNmT50jnSnvjTMsAwWHnZ/PAry7oSTUWqb z98TT6SNfcu4jre/lTvOc9NeMjTt8rOfHMaNJbV6m7rrjzKgVE1JkfFGPeisluLT zxOfmpJTBLmKdV27GZcAs0xx/7LelBmN4UVGGl6nhklSDIXu5dFTG5KH53lwNed9 bYRdM6EyWIzRbjPGDkfq85M21YnEG9rIQIjUQR4OMrvIU1tDMtgQQjYWZ3pn+g5X TY1ogta/AKJSANQP9oNDliQw2tQcSibbRNVIePc6614= ocfs2 uses kzalloc() to allocate buffers for o2net_hand, o2net_keep_req and o2net_keep_resp and then passes these to sendpage. This isn't really allowed as the lifetime of slab objects is not controlled by page ref - though in this case it will probably work. sendmsg() with MSG_SPLICE_PAGES will, however, print a warning and give an error. Fix it to use folio_alloc() instead to allocate a buffer for the handshake message, keepalive request and reply messages. Fixes: 98211489d414 ("[PATCH] OCFS2: The Second Oracle Cluster Filesystem") Signed-off-by: David Howells cc: Mark Fasheh cc: Kurt Hackel cc: Joel Becker cc: Joseph Qi cc: "David S. Miller" cc: Eric Dumazet cc: Jakub Kicinski cc: Paolo Abeni cc: ocfs2-devel@oss.oracle.com cc: netdev@vger.kernel.org --- fs/ocfs2/cluster/tcp.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/fs/ocfs2/cluster/tcp.c b/fs/ocfs2/cluster/tcp.c index aecbd712a00c..929a1133bc18 100644 --- a/fs/ocfs2/cluster/tcp.c +++ b/fs/ocfs2/cluster/tcp.c @@ -2087,18 +2087,24 @@ void o2net_stop_listening(struct o2nm_node *node) int o2net_init(void) { + struct folio *folio; + void *p; unsigned long i; o2quo_init(); - o2net_debugfs_init(); - o2net_hand = kzalloc(sizeof(struct o2net_handshake), GFP_KERNEL); - o2net_keep_req = kzalloc(sizeof(struct o2net_msg), GFP_KERNEL); - o2net_keep_resp = kzalloc(sizeof(struct o2net_msg), GFP_KERNEL); - if (!o2net_hand || !o2net_keep_req || !o2net_keep_resp) + folio = folio_alloc(GFP_KERNEL | __GFP_ZERO, 0); + if (!folio) goto out; + p = folio_address(folio); + o2net_hand = p; + p += sizeof(struct o2net_handshake); + o2net_keep_req = p; + p += sizeof(struct o2net_msg); + o2net_keep_resp = p; + o2net_hand->protocol_version = cpu_to_be64(O2NET_PROTOCOL_VERSION); o2net_hand->connector_id = cpu_to_be64(1); @@ -2124,9 +2130,6 @@ int o2net_init(void) return 0; out: - kfree(o2net_hand); - kfree(o2net_keep_req); - kfree(o2net_keep_resp); o2net_debugfs_exit(); o2quo_exit(); return -ENOMEM; @@ -2135,8 +2138,6 @@ int o2net_init(void) void o2net_exit(void) { o2quo_exit(); - kfree(o2net_hand); - kfree(o2net_keep_req); - kfree(o2net_keep_resp); o2net_debugfs_exit(); + folio_put(virt_to_folio(o2net_hand)); } _______________________________________________ Ocfs2-devel mailing list Ocfs2-devel@oss.oracle.com https://oss.oracle.com/mailman/listinfo/ocfs2-devel From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5520DEB64DD for ; Fri, 23 Jun 2023 22:56:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DD7358D000E; Fri, 23 Jun 2023 18:56:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D616E8D0001; Fri, 23 Jun 2023 18:56:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BDC0B8D000E; Fri, 23 Jun 2023 18:56:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id A93928D0001 for ; Fri, 23 Jun 2023 18:56:00 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 6E2E5120363 for ; Fri, 23 Jun 2023 22:56:00 +0000 (UTC) X-FDA: 80935522080.22.57CA687 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf28.hostedemail.com (Postfix) with ESMTP id 920CDC000B for ; Fri, 23 Jun 2023 22:55:58 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ZG3JSP6Z; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf28.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687560958; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=DznK2AUeRuZJq7eWmkzDsLOFPhbrN3vu6EuXAdMNepE=; b=qKBQBExe4oenjtgRMdj+rYbRy0m5edn7pLuO1Sg7BQCmozQrWcHocdJZzEj8NgU9uPEJtd H+jbtDjghPoL50NKaIc0jQR0w0sqCGGIbLHKxu4D6d32mC+EHKy+cjLa7Z+l1Z5Dc5f9ee rE4U1ZiKfXbmEy1o35Utx2K/vsTJFjo= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ZG3JSP6Z; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf28.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687560958; a=rsa-sha256; cv=none; b=t8kgQ9vEsmAQXsxGgwsxqcJuoYRVEHPyAwQGpyQNepIf5KQGuI6CEdUopZzCOfsiDNyqI/ XZxS0u+SqIKZRRniki+Ictab0OPI8RHRxAngBiBXTNIAZAOiDrLfsfzsrvb3MYQwJjj0oh PduxcfB+c664F2nMv7Nd7g4XZ7P6+LY= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687560957; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DznK2AUeRuZJq7eWmkzDsLOFPhbrN3vu6EuXAdMNepE=; b=ZG3JSP6ZUeHVqA7r+JNZ0VcHokhKWfxGdkCkFSZ4xohgnS0S479xhNIWGytlgoVsxTZSx5 C5EKOM65Ywe0xhh3ldOT7tZ27CPy3ydNrXCH8rUT2JPosMIh/VheRoSGs+FnXhSvhNtY6y WaPjV4+KY0rTCrXJcxKpz4jTrd1bnDI= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-91-scLXM6p0PSyn60UPmGbLlg-1; Fri, 23 Jun 2023 18:55:54 -0400 X-MC-Unique: scLXM6p0PSyn60UPmGbLlg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DCC862A2AD53; Fri, 23 Jun 2023 22:55:53 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8918B40C2063; Fri, 23 Jun 2023 22:55:51 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , Alexander Duyck , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , David Ahern , Matthew Wilcox , Jens Axboe , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Mark Fasheh , Kurt Hackel , Joel Becker , Joseph Qi , ocfs2-devel@oss.oracle.com Subject: [PATCH net-next v5 13/16] ocfs2: Fix use of slab data with sendpage Date: Fri, 23 Jun 2023 23:55:10 +0100 Message-ID: <20230623225513.2732256-14-dhowells@redhat.com> In-Reply-To: <20230623225513.2732256-1-dhowells@redhat.com> References: <20230623225513.2732256-1-dhowells@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Rspamd-Queue-Id: 920CDC000B X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 5mftsekdt6kfmknt8z3wwxhi4r69bqtc X-HE-Tag: 1687560958-526326 X-HE-Meta: U2FsdGVkX190XwC1uAfVhm3NMtUNMf9Ch6CASQNvHwK98MVj1BgN+mYkaRzy3P11G2PZ9yVMyU77fy8zrCsQS784f9X1CUQk9Nex/yMFj446JR2igv+WmaLI7/Xy8u8NgVPAa2VfHEUKBUwX2YnsZUywb0amfXBFFPjjf5AecXyzIvYoIHuX/yEFgynnXBqcJ5Bsjuwo82fgJtRTdUpx6QmJ2LQk4sEivVHHwziJnrbFMFhvsRuiDDfMyk8DaFQS4ndLWUqJzR2zPwrcqRlB7ZC0YHJqsQKEk3+8wJ0hmpOc7DRxjoSd00+n/UvM1UwpskRH/ajQihNzhN2LHJzeR4nx7HYZyk28/zAoxpS8D5oLhQejRdpNBCR/7oZRgL4lnCbrCQWSrOu7xBfuxFlcnXrqPDgp8HCzYcIxB3wsskY5hcUJj0amoZ2s5JFgqlhIOSoAgrGQCaUEeJ6k72wLEI8VFxwJKcJDOo+p5T/fdF2/8H6w01umLtt3he+Fbt4008kbWE1rnhC47yOFOvoAlEAuCK5tY/KX6IMTqewpGUD71vLnml54WIaAe4F2WAFIOvmQcQ2ctDfdxzYmJaQqGLKqJyed+uCzJ/Aql19DKWfNO9I9iUmGF3vDZUL1GerN9+2ZElVid9ZGhUxiyhHZa823Af0oUhDt/VJmCTtDkLSiB85eNeIIKr+MmGJqp9BMyhzPA34bDQT14zjuM1arBHlUasRB2V9QAIhnuJFRrQw2tmwvipua2Wjdgh7ehw3xA1DzCNNMyCwH5u++2+AmvYOfA91BR+OV9IDMkJkw7MR9mbp499VNYByIrDYIoedsOqB7SAxsjkK+F7z5leI77oDUyAU0TayBnCiR/b1vGvUYjN2SopHex34yBCCTkaIt95ZHX7guuSl9HTX7twTTBdqz6d2M5GvGzIiD9SgsjiKBZaZWlghxW3nkK52bJGuo7TNf0qfC4DrcF/t06/o Q/XhorXn eDkFkY+P+Ynh8kK4O8PRJNInMiR0FrShzBjNx2Yayy3/lPGx+4hS1JBuPiRUDw47q+we1gg3EYGfSwWfk9XfsfiCH6lq5P+BQ1flrjSJfiB5wxmtNTpkgGtCSJjlk4uVRXi1rKiWeNddSA5oos4yxQLHni2jKHGW0hVhGgZQiCUB592WbAzux1wSPu3PyRxBeHmKyiHhLNKwJtvna4fKQwgBBHH890XZYcws/+jUPvX69wO7+j7eIZhkMVe4yE7rRKka1TVwMYtjkKC+a2DSAtMHcwPyO/xvJSlEyVY+wSg77hfuK9pX9f3vWComzVlwzdKVvlmW3uSb1UPt4oUg+8jzXYa7XKyzli3riF3OMEMzk5t1KJX4l9fDA/ArAmkjSHRaJ7ZrM3+o45i+tYiBzdr2VrNjlmsd2YwJjCuBxj2vz6If8W77PN/0Tie1wrGwaF1DgN4WFC7cFlg2xcmBlbhco3hqjP2M9orJ1Ab89jR2kzW3NImoT2auypzJ8Qir8GWxNL6HG7TrJPVJpTamMprJqWrFWo2FSPkZCc/dcjiT5k2I= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: ocfs2 uses kzalloc() to allocate buffers for o2net_hand, o2net_keep_req and o2net_keep_resp and then passes these to sendpage. This isn't really allowed as the lifetime of slab objects is not controlled by page ref - though in this case it will probably work. sendmsg() with MSG_SPLICE_PAGES will, however, print a warning and give an error. Fix it to use folio_alloc() instead to allocate a buffer for the handshake message, keepalive request and reply messages. Fixes: 98211489d414 ("[PATCH] OCFS2: The Second Oracle Cluster Filesystem") Signed-off-by: David Howells cc: Mark Fasheh cc: Kurt Hackel cc: Joel Becker cc: Joseph Qi cc: "David S. Miller" cc: Eric Dumazet cc: Jakub Kicinski cc: Paolo Abeni cc: ocfs2-devel@oss.oracle.com cc: netdev@vger.kernel.org --- fs/ocfs2/cluster/tcp.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/fs/ocfs2/cluster/tcp.c b/fs/ocfs2/cluster/tcp.c index aecbd712a00c..929a1133bc18 100644 --- a/fs/ocfs2/cluster/tcp.c +++ b/fs/ocfs2/cluster/tcp.c @@ -2087,18 +2087,24 @@ void o2net_stop_listening(struct o2nm_node *node) int o2net_init(void) { + struct folio *folio; + void *p; unsigned long i; o2quo_init(); - o2net_debugfs_init(); - o2net_hand = kzalloc(sizeof(struct o2net_handshake), GFP_KERNEL); - o2net_keep_req = kzalloc(sizeof(struct o2net_msg), GFP_KERNEL); - o2net_keep_resp = kzalloc(sizeof(struct o2net_msg), GFP_KERNEL); - if (!o2net_hand || !o2net_keep_req || !o2net_keep_resp) + folio = folio_alloc(GFP_KERNEL | __GFP_ZERO, 0); + if (!folio) goto out; + p = folio_address(folio); + o2net_hand = p; + p += sizeof(struct o2net_handshake); + o2net_keep_req = p; + p += sizeof(struct o2net_msg); + o2net_keep_resp = p; + o2net_hand->protocol_version = cpu_to_be64(O2NET_PROTOCOL_VERSION); o2net_hand->connector_id = cpu_to_be64(1); @@ -2124,9 +2130,6 @@ int o2net_init(void) return 0; out: - kfree(o2net_hand); - kfree(o2net_keep_req); - kfree(o2net_keep_resp); o2net_debugfs_exit(); o2quo_exit(); return -ENOMEM; @@ -2135,8 +2138,6 @@ int o2net_init(void) void o2net_exit(void) { o2quo_exit(); - kfree(o2net_hand); - kfree(o2net_keep_req); - kfree(o2net_keep_resp); o2net_debugfs_exit(); + folio_put(virt_to_folio(o2net_hand)); }