From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) (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 9E79734A786 for ; Mon, 25 May 2026 16:13:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779725586; cv=none; b=GG6VBkmX6b6aI+H1hNMMpwHNHpE0SqXXUGrlEJkKxOrKIkqDyulYPjwVlPQObQfrryl5t600hLkH1sm4rO82jZAeKHsISe2rB8AMO7ePFY2/m02LYhrFLky92oFaQqFbnkZQ11WaD1ZsHST3okuKCIACythF7BgCG5miwUCirto= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779725586; c=relaxed/simple; bh=s5w53t4HZEfOpMWOAkkPTvlM5cQcOCdRUzSMehtyGEQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=PBgwXSfg+kMi5Gdpiwqhefc5hhJVTs+19WZqxeNyr9QSOxemWOTmdT1gpCHGr3wvWsmkNaEq/I+h4NV2XK2x43WSZIrU0q8mwT1rjT74mjFuQ2eMmSxdcOrM2/zgrO7MpnnDqFa1svfehs0DFGRFJo3EKl9AK5POkxJKrh6H5f8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=kS1DMu6i; arc=none smtp.client-ip=209.85.221.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kS1DMu6i" Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-441209fb77eso6015728f8f.1 for ; Mon, 25 May 2026 09:13:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779725583; x=1780330383; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=PrUkFmsyhM+H1pzZoLfPMsL3Oa/eAQefGicPa01J8aw=; b=kS1DMu6iT6wKVRxaPin7EgPS7Cw9/Pt3WcjoUuYVh9fpumC5IoI/6d1RkxVJfBuVtS VWVIpYdKK5RzWqtObG8JD5M91ESXgm9MROtxzeVHJu4FkMcK/tRAPBJOt++CjlF8bOrJ viTwzjeTTdLZ14eluw9HcGFfMkic6lDfqgfzxKVuFzQ+Joa5uDV30/AP6Nr0Hwx/4urj k37EdlUQoyANmWVkoQRyMKjYhnppCQZddKZK23UH4Fl61SX7QuBjSQAfOmN+mb7TwtJi hwL4PW0fyWVAsCsxD0n9l7gWFKnuFKAn5MLjiZHnFXsbvq65wC/xV2LmM3nAbrJ6LGb9 CIjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779725583; x=1780330383; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=PrUkFmsyhM+H1pzZoLfPMsL3Oa/eAQefGicPa01J8aw=; b=mUWmafvtfGgnnSFOJEI8AgjZS7GqL4/5JJE4xN3QjaGNJWc5WKist1ASLDW8LUPr3L DXzPIxVFhCKBYb4sFvkmFc21R6N3bE1sDtS0W2FZ8olSqtwYXRVsHx7KPim1D5scD8ou sVCOHaCXoYK/xVsTbvJjDtiB1SCtIOab16j8s+3P63iAXKKSKBs9KQbzlTgbnBakLP6/ 6kaD3Yxsk+s30H4xSuVRIPV90CV60Ic5JPG+nA/ZBNtnenCH3USsljUhnoGKOX/3KopP Zn7ARTV81ARWJDm3bIkgsNdG4oqGtjdegrXHZTJybfMYl2iVQSpTbQCA3oW3rlixTidu gcVQ== X-Forwarded-Encrypted: i=1; AFNElJ+/lEIoRtneAb7VT7wCHMqI0PJXFFAIh0kBPEYou183jRhZoo/KjE+L85ND30ohyXxD0A+/0eGqFhNnwY8=@vger.kernel.org X-Gm-Message-State: AOJu0Yydix0hhtxjkLDjcZUuEF0vBW9WysYXM8zfnmt6hsQxNyihh6g9 r8e2M69XTLMnNNcZisfdj/1PjaXILIPXTOKRgIfatxAvQ/p82aI/71/3 X-Gm-Gg: Acq92OEeTTb4OUK1weSFXB+7eVgRSnrbwyiKhlqk86cJmgz3NAS6j22Sc5/ELeerp15 xyY0AwfnAFd0KwfdIR+6jHXzbGVmWRO8+GBSEGsGoVKy6d/Tra/vzEuKuGTb9y+nm0r1nos81lr 3R697X2KMB65MHLGXseuXV+tqYzl7JFEz9do+5UR1hEMJWRCyjMqSNdYSdYc/7wfShPmSWLHMY8 NJEBkQLsecvVv8IMe0A34nE3gMVKyify9XaHqnNpY9EUH/obTNFE3Fr4vIYAlFpUZzMwUkiFlu4 Uz/r/xIYOUc6ZpKTZJFMzW92lu3t1k6CRnitvVyAlaQiLLOMQNYEyhIUOW4Rydrw/0jTv4O2Wev k+CKRsbFX3fHTCoCX20ZZ6u6wYu4/RI/aopcgOKYQ4ySMbuBsjGg6X/rBS3iB2CDrNvRlxTzjve kFAs2a/MMHC+cMcnyv7v3St50fi+xMKdpyqg== X-Received: by 2002:a05:6000:1889:b0:45e:8edc:dacc with SMTP id ffacd0b85a97d-45ea31ce398mr31640895f8f.27.1779725582779; Mon, 25 May 2026 09:13:02 -0700 (PDT) Received: from localhost ([196.207.164.177]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-45eb6d47b82sm28136573f8f.19.2026.05.25.09.13.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 May 2026 09:13:01 -0700 (PDT) Date: Mon, 25 May 2026 19:12:57 +0300 From: Dan Carpenter To: Maxwell Doose Cc: Nuno =?iso-8859-1?Q?S=E1?= , Jonathan Cameron , David Lechner , Andy Shevchenko , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: Re: [PATCH] iio: core: fix uninitialized data in debugfs Message-ID: References: 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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Mon, May 25, 2026 at 08:17:28AM -0500, Maxwell Doose wrote: > Hi Dan, > > On Mon, May 25, 2026 at 2:19 AM Dan Carpenter wrote: > > > > If *ppos is non-zero then simple_write_to_buffer() will not initialize > > the start of buf[]. Non zero values for *ppos aren't going to work > > anyway. Test for them at the start of the function and return -EINVAL. > > > > Fixes: 6d5dd486c715 ("iio: core: make use of simple_write_to_buffer()") > > Signed-off-by: Dan Carpenter > > --- > > The original copy_from_user() code was better: > > https://staticthinking.wordpress.com/2026/05/23/simple_write_to_buffer-is-complicated/ > > --- > > drivers/iio/industrialio-core.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > Codewise looks good but often times people will prefer > > if (*ppos || count >= sizeof(buf)) > > over > > if (*ppos != 0 || count >= sizeof(buf)) In this context, I feel like either is acceptable since zero represents the number zero. I have a blog about that which I have been trying to promote. #SEO https://staticthinking.wordpress.com/2024/02/20/when-to-use-0/ > > Regardless, > > Reviewed-by: Maxwell Doose > Thanks. And you're other comments with regards to -EINVAL and -ENOSPC are obviously correct. regards, dan carpenter