Received: by 2002:ab2:7a55:0:b0:1f4:4a7d:290d with SMTP id u21csp183298lqp; Thu, 4 Apr 2024 10:03:27 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWjnqYSnAItQEN9XncunQiSJ3hTRqkLsiQyXEX7p5MMbqpYyDBxlrdwH+0xd/AVbculGTFMqHBeuAMQl6X+dQmvbiJ7cjB5yq9I4Qgc3w== X-Google-Smtp-Source: AGHT+IGwMSJogjgPSSl5Y2x0HyZ6gRH+EXpvJ+LMBU2V86ITDOsXarYqDAUGQsrH3kaJtywcOfoC X-Received: by 2002:a05:6122:10db:b0:4d9:218e:3fdd with SMTP id l27-20020a05612210db00b004d9218e3fddmr321560vko.1.1712250206700; Thu, 04 Apr 2024 10:03:26 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712250206; cv=pass; d=google.com; s=arc-20160816; b=LucNrrhLpyg2PSpWAObq+OcTbzJrbopBPCDCyXFDnZn9pQrqvJLYcQq17+xYcLXdNs mGiCR3Tp18lDl8drqhrmrncMEGnMTNOmEOrlj3hjJrZAtMWOD1G1Gd4I1bmWuiNL8BwA yknkFw/nfRZmImcLPohe5CHalOXBYCcfuoUgoDKSwV7ZQHphDuJg2CFjefvMKD9dxO6A dVMgozEmw2z90Qg3MXll6BviYIfUcys6lajSEaM6Wq4rPvINuyjPYzD8ki46Y1X4VjE2 /DY6N0Zq5Oj3Yc6V0djB+/atv/Dwl5u3s4Nkmya4yc1/TFTFyNhX3QWJ8tcLsFvlBP0v mXCA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:content-language:from :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=nwW15y/gevLBo/37k7raCy6SimB0lfU8Tu3YYMej9TU=; fh=GtLaBXuYOF/LmPg96mqe0vb6KaQazvd1WoJj4IOXkOg=; b=IqZUSS51yjH2nuSKquTQk6gq98JnY3MtctWjlr2by/0/4Yay8NysO1T/VA9aJo8QWG 98NzT7XJ5TQyeQXy3Z78UWjJ+TqH7EyftibxUZZ8q2C98B0FcZuC+6Y+pG3bilWUkABQ rIP6z1IX7lwGQPOFVkkFESIKisdD/hoTPVXwp85Kjwr198EOlprobU0JT88ImUyPcIbl 6Bsc4XTRA7b0Pl62/bUAaIAEBFIhgaNHoe1bXe7OtdDKO0q+MEQOhEWJgDLf5UFxzx8x XIV990OgOtpWdYFNp8hlJ+3EDs8hOSeJJuBZgvHjnbZa9K2Qln5AYInmKAeNoNFjOKR2 UTiQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Dc3+AVDp; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-131683-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-131683-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id bf22-20020a0561023a7600b0047849791eaesi269759vsb.230.2024.04.04.10.03.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 10:03:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-131683-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Dc3+AVDp; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-131683-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-131683-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 8C7C41C278E7 for ; Thu, 4 Apr 2024 15:12:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 973A7128362; Thu, 4 Apr 2024 15:12:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Dc3+AVDp" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.14]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2D9491D551; Thu, 4 Apr 2024 15:12:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.14 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712243529; cv=none; b=oZAKbZyACid+P6UIEd1EIPVPDswjf1pZq1L8sc7S0nDi7ItVU5GhAquW9GO3W8vCoU8bL48l/zs3LZGAXJMdMF8L5NYbbYpgsLP7jrniSsju+zZF2FoAhB1IKRKCMMp+NOkeqE5DwpGlC3RitXdb2/aPAM55oQ6boATjiP+WkkY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712243529; c=relaxed/simple; bh=J1aqCHl4RlvByCEFGZ60+2vPpqa4aKe6g5qYLLoW0CI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=WUW8zq2njdAi9h3H2wQ9MlTohOjKCCbCngfWjkg5XmuDIOSamhxFW86yUAO8PD7jlfkrMh2nuRyuhrRvLV+CVzQ9oX1IQYpW8gqbpQVAHW3o/o9zOs0UJBrDODZnGwHk6cm8thrWpU0YuSxFgGyn64dSJmT9ZSH6MN54BJJkRBo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Dc3+AVDp; arc=none smtp.client-ip=198.175.65.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712243528; x=1743779528; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=J1aqCHl4RlvByCEFGZ60+2vPpqa4aKe6g5qYLLoW0CI=; b=Dc3+AVDpodc3alHA0dmsqxF6ClKugBDF7/XTS2MwaT/7Gq+npGwklAL3 zm+hsm1l3g2glFjQ1YcN6c4UPpK56V5N5Fbypxp0Zujkz/R7+dupuj3Vg 9VWDSYiqyFCPvLKgwhod0tWfUfzweMjyXATJ3/Tixs6raJNbFURHEOC9t IGTPIz8crVFKwSx5uZsCkA7UjKdpUkoqDH856a4LfDzInz38TY2kWo7vy i1IjzNAKSBsQRojYxm2f8oeInV9Fo9gx0N5fvHPJvxKh2C6KKRyG/CM1Y ezzYs2aHpsp1Wq/t6/shaJAApJ560wQbm1ke0p7fcHKHKwiwznXlQXRXz A==; X-CSE-ConnectionGUID: oHke3O1MQ+iUPrXb3nkyPw== X-CSE-MsgGUID: x7yeo/CiRUOF+77ysEWvnw== X-IronPort-AV: E=McAfee;i="6600,9927,11034"; a="11355536" X-IronPort-AV: E=Sophos;i="6.07,179,1708416000"; d="scan'208";a="11355536" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Apr 2024 08:12:07 -0700 X-CSE-ConnectionGUID: JEZ3/RujSLiVwTylxe6LDw== X-CSE-MsgGUID: 7XRf0ZZKT4u4MRwLUuR2FQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,179,1708416000"; d="scan'208";a="23282962" Received: from aghiriba-mobl.ger.corp.intel.com (HELO [10.251.213.116]) ([10.251.213.116]) by fmviesa005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Apr 2024 08:12:04 -0700 Message-ID: Date: Thu, 4 Apr 2024 18:12:35 +0300 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] ASoC: SOF: Clean up sof_ipc_flood_dfs_write() To: Dan Carpenter , Pierre-Louis Bossart Cc: Liam Girdwood , 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 References: From: =?UTF-8?Q?P=C3=A9ter_Ujfalusi?= Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 04/04/2024 10:34, Dan Carpenter wrote: > 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 Thanks, it makes sense. Acked-by: Peter Ujfalusi > --- > 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; -- Péter