Received: by 2002:ab2:2441:0:b0:1f3:1f8c:d0c6 with SMTP id k1csp108347lqe; Thu, 4 Apr 2024 00:42:52 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXyiNeFTh91cir7Vw6RoLPHVBQr+6MJcpN7wexWEPOrRQ/Iyy5jEImpzIfTCd2DWNYRfhfz3kDKiEYB3QaL+YeNohnYQiRER2K1gTHjlg== X-Google-Smtp-Source: AGHT+IFGx8wGV7MgnnNiwORYPBd6sYlinTdNKi9sTIfunL5vG1p0txgJiCRE2uBlW7AaXevu5nLl X-Received: by 2002:a50:d6dc:0:b0:56b:f2d4:8d9 with SMTP id l28-20020a50d6dc000000b0056bf2d408d9mr1067521edj.40.1712216572769; Thu, 04 Apr 2024 00:42:52 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712216572; cv=pass; d=google.com; s=arc-20160816; b=doMJ/jhNGMd3esQZaiMqeW46WHXdEVTg+524kDYVNqSyRtuERDb1UEFxnTvNyrm+pO 0bs8fZ5OH5RBUF5IMCjBy3TaRr5MiHfFITGYRRDc8wXzxCO59LDWAOCg7Ftt9prIyAEI cr+kRvEV0Cn7UjxK/7cPLmt6i95ygIg0DNDQtCNquPWD+2IcXGA2UlSZv34oi80mZk4X ifJo5FeVLmtyt2WI47SeY2o5I+yIIObwIf42niPZGSWoxDGkdeeUJjbgJqmr6z3g35yx XQz8/Ws0mYUWwERhVG8mtJHXw7rKX9e54uumaVWYkcMlH3e/aM+XEmLBh0wdcnNexhwd eqPQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-disposition:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:message-id:subject:cc:to:from:date :dkim-signature; bh=3vvDcJ9owmc8iAbT8weYpAHg2loA4AsSc9MH9lVIiwo=; fh=rWlHhh7T8aPEVVh/klAJMuuZaiZxx685sS1Dz5fGEBA=; b=rOmWrNJ6gGbWezS3QaDB0mRU/gWDknntSeUbEFQywCaRcn8Wo3kKP4bdlb9/B4b4ff LRKgeNZbWvG5M3/fhVqnxPY107VuSgDm/+IHPty0R8wY4DekEFawGKEL/hNvYh+ChHBV E29cUUlLTiB+kLwn3PgnNI5HLVHYfDM57jzcES4STsSjB0KBH3CHmQ87UC3lV/HviyXb a86iyLE2HYjav1yjv9LoUWPUzuorzretr4dEGNJKMYySGG3Ms8lg4iufY+gJFgEtqWEh CUfM+Q9ufUU7wibSeaQ2ZE/YJJoCC5h3QxkqZlPxb4tGDO8EgHuNRlL16/2mhrx7WiuO zrtA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="nnrs/DkW"; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-131038-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-131038-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id r16-20020a50aad0000000b0056df90d0404si2000499edc.303.2024.04.04.00.42.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 00:42:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-131038-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="nnrs/DkW"; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-131038-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-131038-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 1DD601F22E78 for ; Thu, 4 Apr 2024 07:35:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 722645C606; Thu, 4 Apr 2024 07:35:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="nnrs/DkW" Received: from mail-ed1-f47.google.com (mail-ed1-f47.google.com [209.85.208.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E984645970 for ; Thu, 4 Apr 2024 07:34:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712216100; cv=none; b=Z/uxNUgGYJCKAVPWbtZ8ZhBTpVcMzY6PURV0SDpQxuuQh7m3ivciOW+WQIDpFOCeOLIpLqK/WEro7xCMxImNlBAhFNkMdlrHlMAEVvVpX+swokVdAyANoQz+9Vs9B3jL32Mgt5fUcheYbj17J+tnxEeHeGWho1xDLoD1X2VGChY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712216100; c=relaxed/simple; bh=W7e7+MAaGHn/4hurkaunIgg5XW7NXfDrp6QPkdem9OM=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=cjnQXQGxL50Wck1r/UFCyXYQlG/72xjnEpq6ygiu/P2gvUJY/4lovXtnvaKRoZM9IMLilZMd6pjX3EvUojO5o3+R8ZH9eZ/mXOzXqaDOP27FdvYU8c+52cD6ehuyDWpTSn/DUC8XWwzp4sbIoLUlroKRz4ptzsc44/CB645BWiQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=nnrs/DkW; arc=none smtp.client-ip=209.85.208.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-ed1-f47.google.com with SMTP id 4fb4d7f45d1cf-563cb3ba9daso619386a12.3 for ; Thu, 04 Apr 2024 00:34:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712216097; x=1712820897; darn=vger.kernel.org; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=3vvDcJ9owmc8iAbT8weYpAHg2loA4AsSc9MH9lVIiwo=; b=nnrs/DkWGLkcUnFrcBSp1PkLO3s6A5k3KmQ0grKi17XCQqzSTHLrtItsEuZDisMWGo EctrGpmi9HkjVKqpcsiiXMLRxAuND4V9nkEelwXZAAJiheftkBQIi3X2f2uSGu1zapPI R7VtumxnjFF7eToybgMKC5zhE44rK2IRmASyAEMpae0Ed5qF3ADvpaqdEXuRbQvbndKP XpGZ7BYH+51FRMUsPddsu5rIgW728eKI3CjFdXf8JzzRMlEsHwlyVdK5Vq3xta7GWMJk s8oeFST5Cf4VrIE76KtxLHLybEctlHqY2foWSMeH1dq5PyzawZIW75iD+Rn/Gjy5KbLm +gkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712216097; x=1712820897; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=3vvDcJ9owmc8iAbT8weYpAHg2loA4AsSc9MH9lVIiwo=; b=HfE0aZ0MSQql5IlVDmTSdLqc8AlsbWnSNFOw7H7Mx4viBQPYoDqbeBuHXrWffKPn9V 8IkvhHv+bFv/2/35Nw+2PgRearbIVvGyQhXeqqNrLhHoCEdD52x5A9sIXPifxQuj3okV 45isza5ZPYoN+xKU5ILeC0B9d6RgbTPdQ6/6TSRVhePs88nvbmJLTFWRQ31aJU044o3g MuWwwhpyq4z/vdXIOemUaX/1ngKjLG8Kxtz8wRwySmfceMRkzSyZvT1s1X/v8/uV0tBN b9reiGnMVGMyWyXP1RsdUmmL77r7Ppr1J9uw1wVvesHMoPEemx3IPvVDk9sP02hcWvjI b+9Q== X-Forwarded-Encrypted: i=1; AJvYcCXSLlSHaagUtZD+q66rSa9wmV5Aozmse7k8xoLIwsugXLg9ukwQtt4boFgj6xnjwCAN6Hr4iqDMKrcENW24TbofsS8cmkDyorq3+Wf3 X-Gm-Message-State: AOJu0YwMNz2epXoQQJAlfunwIBPeeXeqPtKopV50A4Aon259XyyOtuJa 74X+Jml6KVkbLK4tEwFXlzuQVqXgGvWIN7x3muyTWJGCs9KnIQq3o6wBw760Zog= X-Received: by 2002:a50:9301:0:b0:56e:22a1:a9a2 with SMTP id m1-20020a509301000000b0056e22a1a9a2mr18956eda.33.1712216097224; Thu, 04 Apr 2024 00:34:57 -0700 (PDT) Received: from localhost ([102.222.70.76]) by smtp.gmail.com with ESMTPSA id g28-20020a056402321c00b0056c1c2b851esm8934205eda.0.2024.04.04.00.34.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 00:34:56 -0700 (PDT) Date: Thu, 4 Apr 2024 10:34:53 +0300 From: Dan Carpenter To: Pierre-Louis Bossart Cc: Liam Girdwood , Peter Ujfalusi , Bard Liao , Ranjani Sridharan , Daniel Baluta , Kai Vehmanen , Mark Brown , Jaroslav Kysela , Takashi Iwai , sound-open-firmware@alsa-project.org, linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH] ASoC: SOF: Clean up sof_ipc_flood_dfs_write() Message-ID: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Mailer: git-send-email haha only kidding This function doesn't support partial writes so using simple_write_to_buffer() doesn't really make sense. It's better to just use copy_from_user(). Signed-off-by: Dan Carpenter --- sound/soc/sof/sof-client-ipc-flood-test.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/sound/soc/sof/sof-client-ipc-flood-test.c b/sound/soc/sof/sof-client-ipc-flood-test.c index c0d6723aed59..1b2e9e25a836 100644 --- a/sound/soc/sof/sof-client-ipc-flood-test.c +++ b/sound/soc/sof/sof-client-ipc-flood-test.c @@ -160,15 +160,20 @@ static ssize_t sof_ipc_flood_dfs_write(struct file *file, const char __user *buf unsigned long ipc_count = 0; struct dentry *dentry; int err; - size_t size; char *string; int ret; + if (*ppos != 0) + return -EINVAL; + string = kzalloc(count + 1, GFP_KERNEL); if (!string) return -ENOMEM; - size = simple_write_to_buffer(string, count, ppos, buffer, count); + if (copy_from_user(string, buffer, count)) { + ret = -EFAULT; + goto out; + } /* * write op is only supported for ipc_flood_count or @@ -198,7 +203,7 @@ static ssize_t sof_ipc_flood_dfs_write(struct file *file, const char __user *buf /* limit max duration/ipc count for flood test */ if (flood_duration_test) { if (!ipc_duration_ms) { - ret = size; + ret = count; goto out; } @@ -207,7 +212,7 @@ static ssize_t sof_ipc_flood_dfs_write(struct file *file, const char __user *buf ipc_duration_ms = MAX_IPC_FLOOD_DURATION_MS; } else { if (!ipc_count) { - ret = size; + ret = count; goto out; } @@ -231,9 +236,9 @@ static ssize_t sof_ipc_flood_dfs_write(struct file *file, const char __user *buf if (err < 0) dev_err_ratelimited(dev, "debugfs write failed to idle %d\n", err); - /* return size if test is successful */ + /* return count if test is successful */ if (ret >= 0) - ret = size; + ret = count; out: kfree(string); return ret; -- 2.43.0