Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp252204rdf; Tue, 21 Nov 2023 01:24:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IFsGxczJ+HAJ0KXY95j1DNrU3XX0OeA7tA1cUEDSATJIaOlLOxxVhZRXQCwROEQURTTbukV X-Received: by 2002:a05:6870:b4a8:b0:1f9:46c9:966b with SMTP id y40-20020a056870b4a800b001f946c9966bmr5180194oap.49.1700558654920; Tue, 21 Nov 2023 01:24:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700558654; cv=none; d=google.com; s=arc-20160816; b=kjtFSblMIq5x4o3zKxe5neXr2NXM2mQ351mvwMdSf+U2Gu2BT6A4DtqhOZsyC3dq53 uZZpXnm6LtLyt+8sdDMy4nMAZQa4AaOh0z2foHJkH1TZvN7CABW/6oZmFwiGAb3PAfjm lFIPVXvXMUVN5/ezZ5sHDAt/r/vgMXz+ufztzdSA9EwwVM25POHkAPbyKq1binOGV62X ZOgvDisG7Cw+N5J3Ef1P80SuKu8H+xwLLp797anm0w2345UJe1sA3qW4nGNsQ+tTBg8K h5z9aeTomQivYXRIjMfKOsSOsEdfBAC5l+IwkVONXvpF91wHOSQGBFRhEI2i7duX0WLE 9bTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=zFXcosUqwK3+BT9sDqsIuLTTW+VJb6ME1l5apsAkWoE=; fh=huxwEvEMuYN0smhsXEMROEwL5iJSk46It4GOnKU4+sE=; b=zCJPBe5cUnd19lY2/y1hX1PTwGxR+7FgreA+x2lyl6ahcZekDk/7fS4m+tg1YXSt68 kkamEnBCgJhZzal0msI+vZUzSi/X1yMAxJx27nSLJjTO1icn6zStV3FNc3gxXgnU/rp7 tJqmYSyqmcuI6declUiiN4s8oAK8nFpwi59wvm5bx+CYmBOhjMn1j//wvpdRA27mYHQP xv4olwIeyNd3DSyi/A89qNQCV2Hh/nEAA06HEMI4c7gqgJcNZAZ2elE8Bnyix7oE+5Uv Pr7M5Mit+MQgGaSfi8v/8VZME7tdhOyeZVDy97N/1o56g+gUEYqTYdxtq99fu7xgiXPw J3Nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XMaaAFxt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id b15-20020a65668f000000b005bdf5961dd2si10033777pgw.400.2023.11.21.01.24.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 01:24:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XMaaAFxt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 447E580CD733; Tue, 21 Nov 2023 01:24:05 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231419AbjKUJXf (ORCPT + 99 others); Tue, 21 Nov 2023 04:23:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232812AbjKUJXU (ORCPT ); Tue, 21 Nov 2023 04:23:20 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74870198 for ; Tue, 21 Nov 2023 01:23:15 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AC1A6C433C8; Tue, 21 Nov 2023 09:23:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700558595; bh=1ot3xOBoOP7h0U8F/4uFP8Qnn04pPCBCsYAQSIl1nS4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XMaaAFxtaDDQ56o7fXs0QGyJcFgyPvsmGh4mwdScBGVHv6QbGWvjUyLtBXJ/f+KuA ES0RVOIH2egtSF87/OHQecYS33l9Spw874MqkkK61gISBS5zFMgvG9tTjmiWBAvPTB ATJPBITN4yxZB9bPfXrJfbnzHQp0FdmotvxpyqJW/ocA/UfrLslKHaIQbbAdaby4zp QwjGZqMr4CZ0qPCu/+NaBP2kBb4DFEHQZBwpcBaIN2IJ8SaG75NZWm/MJfKYBLjObi uCBIjbzCMh+ZNi5Z6jiBQQRevsVtxJ8GWrV4auGzSjcn5+SL6YORjtdCp56fcZ1ApB ockXOFliS6RKQ== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" , Laurentiu Tudor , linuxppc-dev@lists.ozlabs.org Subject: [PATCH 07/17] tty: ehv_bytecha: use memcpy_and_pad() in local_ev_byte_channel_send() Date: Tue, 21 Nov 2023 10:22:48 +0100 Message-ID: <20231121092258.9334-8-jirislaby@kernel.org> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231121092258.9334-1-jirislaby@kernel.org> References: <20231121092258.9334-1-jirislaby@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Tue, 21 Nov 2023 01:24:05 -0800 (PST) There is a helper for memcpy(buffer)+memset(the_rest). Use it for simplicity. And add a comment why we are doing the copy in the first place. Signed-off-by: Jiri Slaby (SUSE) Cc: Laurentiu Tudor Cc: linuxppc-dev@lists.ozlabs.org --- drivers/tty/ehv_bytechan.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/tty/ehv_bytechan.c b/drivers/tty/ehv_bytechan.c index a067628e01c8..cc9f4338da60 100644 --- a/drivers/tty/ehv_bytechan.c +++ b/drivers/tty/ehv_bytechan.c @@ -143,9 +143,12 @@ static unsigned int local_ev_byte_channel_send(unsigned int handle, char buffer[EV_BYTE_CHANNEL_MAX_BYTES]; unsigned int c = *count; + /* + * ev_byte_channel_send() expects at least EV_BYTE_CHANNEL_MAX_BYTES + * (16 B) in the buffer. Fake it using a local buffer if needed. + */ if (c < sizeof(buffer)) { - memcpy(buffer, p, c); - memset(&buffer[c], 0, sizeof(buffer) - c); + memcpy_and_pad(buffer, sizeof(buffer), p, c, 0); p = buffer; } return ev_byte_channel_send(handle, count, p); -- 2.42.1