From nobody Mon Feb 9 05:57:48 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E295DC7EE2C for ; Tue, 30 May 2023 14:20:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233101AbjE3OUc (ORCPT ); Tue, 30 May 2023 10:20:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233104AbjE3OTC (ORCPT ); Tue, 30 May 2023 10:19:02 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A558D1B1 for ; Tue, 30 May 2023 07:17:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685456264; 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=jD4W/W7iXB9ATeRl2QuO5GnCDoE2m4ZXOMCYUAgCXGY=; b=b5xvXsDKmw/Mz3esMh3MA7eYsMz6AyxK6ORbp9jDt8PdaXy90M7kEWXvizjeRkgVSZyx4b FqK6CWmYVDhrLCqlgWWhE7IJB13QRtiaI/DUjIaum4kU7R43RyrzJhEwlNbTZCmXoL7E0F mKp6jCFmTf2hpJORZYbrpMFOLYncrTc= 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-210-n8AGTfiBPVSP1SnUgycr9w-1; Tue, 30 May 2023 10:17:38 -0400 X-MC-Unique: n8AGTfiBPVSP1SnUgycr9w-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EF71E38154EB; Tue, 30 May 2023 14:17:37 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.182]) by smtp.corp.redhat.com (Postfix) with ESMTP id A08D1140E955; Tue, 30 May 2023 14:17:35 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , Herbert Xu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , David Ahern , Matthew Wilcox , Jens Axboe , linux-crypto@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v2 07/10] crypto: af_alg: Indent the loop in af_alg_sendmsg() Date: Tue, 30 May 2023 15:16:31 +0100 Message-ID: <20230530141635.136968-8-dhowells@redhat.com> In-Reply-To: <20230530141635.136968-1-dhowells@redhat.com> References: <20230530141635.136968-1-dhowells@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Put the loop in af_alg_sendmsg() into an if-statement to indent it to make the next patch easier to review as that will add another branch to handle MSG_SPLICE_PAGES to the if-statement. Signed-off-by: David Howells cc: Herbert Xu cc: "David S. Miller" cc: Eric Dumazet cc: Jakub Kicinski cc: Paolo Abeni cc: Jens Axboe cc: Matthew Wilcox cc: linux-crypto@vger.kernel.org cc: netdev@vger.kernel.org --- Notes: ver #2) - Fix a checkpatch warning. crypto/af_alg.c | 51 ++++++++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/crypto/af_alg.c b/crypto/af_alg.c index b8bf6d8525ba..fd56ccff6fed 100644 --- a/crypto/af_alg.c +++ b/crypto/af_alg.c @@ -1030,35 +1030,38 @@ int af_alg_sendmsg(struct socket *sock, struct msgh= dr *msg, size_t size, if (sgl->cur) sg_unmark_end(sg + sgl->cur - 1); =20 - do { - struct page *pg; - unsigned int i =3D sgl->cur; + if (1 /* TODO check MSG_SPLICE_PAGES */) { + do { + struct page *pg; + unsigned int i =3D sgl->cur; =20 - plen =3D min_t(size_t, len, PAGE_SIZE); + plen =3D min_t(size_t, len, PAGE_SIZE); =20 - pg =3D alloc_page(GFP_KERNEL); - if (!pg) { - err =3D -ENOMEM; - goto unlock; - } + pg =3D alloc_page(GFP_KERNEL); + if (!pg) { + err =3D -ENOMEM; + goto unlock; + } =20 - sg_assign_page(sg + i, pg); + sg_assign_page(sg + i, pg); =20 - err =3D memcpy_from_msg(page_address(sg_page(sg + i)), - msg, plen); - if (err) { - __free_page(sg_page(sg + i)); - sg_assign_page(sg + i, NULL); - goto unlock; - } + err =3D memcpy_from_msg( + page_address(sg_page(sg + i)), + msg, plen); + if (err) { + __free_page(sg_page(sg + i)); + sg_assign_page(sg + i, NULL); + goto unlock; + } =20 - sg[i].length =3D plen; - len -=3D plen; - ctx->used +=3D plen; - copied +=3D plen; - size -=3D plen; - sgl->cur++; - } while (len && sgl->cur < MAX_SGL_ENTS); + sg[i].length =3D plen; + len -=3D plen; + ctx->used +=3D plen; + copied +=3D plen; + size -=3D plen; + sgl->cur++; + } while (len && sgl->cur < MAX_SGL_ENTS); + } =20 if (!size) sg_mark_end(sg + sgl->cur - 1);