From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-180.mta0.migadu.com (out-180.mta0.migadu.com [91.218.175.180]) (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 093EC3E835C for ; Mon, 25 May 2026 09:37:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779701823; cv=none; b=cYisVQXpNduI24acwKzUJJb+4YqDCL1Gch7Lw8alvyGoXVmjLByMkniNcWiD27gC0dfQ1TYZQLxoV4bWgOr7393pXPYirKd6JsFtWBdQ7OUhgS0PNWFLnRChkDpg/883Zw9r0Ke2LqzXOR/mL2l/R2MlDj4/E5mFgCSmMzlyCH8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779701823; c=relaxed/simple; bh=FLBl89QevgzuFyYEiIYWIlO/5BFsrsWKMTczWwDifqA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=QufVHoEEyC8jLywhh30JQc1x070lb46i5V5SUBysa4rSJNksimr8t0uuliH2Lvr0sDidoDISvOBjCd0oGdIAc9uvOG+p7py19a9BK7H0xXHt9+tRJirp9MfKvRFfU/qMsbJ/m8TgVdBUbleFtSxfZx+Ls+zqj/D1FF3Ad/bUdKU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=ITEMvkyD; arc=none smtp.client-ip=91.218.175.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="ITEMvkyD" Date: Mon, 25 May 2026 11:36:51 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1779701819; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ZnQ9RgKaNsNwcPR6h/jF/G5/iqFMlMJPbSMjyRrPPH4=; b=ITEMvkyDepRUxpz/GvZIhxeNE12ljx8AEJKrhfQFdjpCLScZUyQDwT6EyTn0jSXOFpA7Rl Ajlz9d93Bm+4vISbWdPlhs+tgCByaY8hjvCcXavxCCLUXYUz0JQc5Q+b5Sr+7cemVztqJJ DQuXt/L/vS74HSE4SvuY+sf18h5kBsE= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Thorsten Blum To: Alexander Shishkin , Maxime Coquelin , Alexandre Torgue Cc: linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH RESEND 1/2] stm class: Replace kmalloc + copy_from_user with memdup_user Message-ID: References: <20260402165933.895706-4-thorsten.blum@linux.dev> 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 In-Reply-To: <20260402165933.895706-4-thorsten.blum@linux.dev> X-Migadu-Flow: FLOW_OUT Gentle ping? On Thu, Apr 02, 2026 at 06:59:35PM +0200, Thorsten Blum wrote: > Replace kmalloc() followed by copy_from_user() with memdup_user() to > simplify and improve stm_char_write(). > > Allocate and copy only 'count' bytes instead of 'count + 1' since the > extra byte is unused. > > Signed-off-by: Thorsten Blum > --- > drivers/hwtracing/stm/core.c | 12 +++--------- > 1 file changed, 3 insertions(+), 9 deletions(-) > > diff --git a/drivers/hwtracing/stm/core.c b/drivers/hwtracing/stm/core.c > index 37584e786bb5..49791024bb86 100644 > --- a/drivers/hwtracing/stm/core.c > +++ b/drivers/hwtracing/stm/core.c > @@ -645,15 +645,9 @@ static ssize_t stm_char_write(struct file *file, const char __user *buf, > return err; > } > > - kbuf = kmalloc(count + 1, GFP_KERNEL); > - if (!kbuf) > - return -ENOMEM; > - > - err = copy_from_user(kbuf, buf, count); > - if (err) { > - kfree(kbuf); > - return -EFAULT; > - } > + kbuf = memdup_user(buf, count); > + if (IS_ERR(kbuf)) > + return PTR_ERR(kbuf); > > pm_runtime_get_sync(&stm->dev); >