From nobody Tue Jun 9 00:49:57 2026 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.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 688203C552C for ; Mon, 25 May 2026 07:15:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779693323; cv=none; b=jncW8ZmK/SKwvsyTGA1yelhPZzIH++xCRMNNiS3Su43seTCA7fjZ2O6zoFC7PPnMM8OT/z8kesjmYYoh04CLHWscRX8es4CESyohhQP+tYukKr/fGufs5uVcoX/i0qPSuudm8/biJWRD+Gvdap/eef21KOZSX9x4zxLOmfNV8TU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779693323; c=relaxed/simple; bh=mZ4KnxOox8XVDHY1nDh0/a8GjdvSDmvGTIyanCnS7MU=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=NsX7gAAmTR4xKBXXbxyRdvpWoo4e9vUuQthvbL6DL82LY9x9ku6NNpvaTIJvHLMWXN5jEnxk5+9f2VFKPE/Ld9l+WrFjtW22JEKP+fORSCUQBIzL1bL8cIzk4DZrc2f/YE3FlDwee6eUIXa//yqSuEQwoBo10ziEq8ulonoqpqM= 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=g5kGxe9R; arc=none smtp.client-ip=209.85.128.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="g5kGxe9R" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-49048e043e5so17788635e9.1 for ; Mon, 25 May 2026 00:15:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779693320; x=1780298120; 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=47oa6+bWcTdZtRyJkBYrwULdTRG5mV9VUpeXnfu9Pl0=; b=g5kGxe9RYQGtcMrjBYQ/Rb5QZHkPY7D25USs8q0oHmHMqphXLXGvitgte9f9TSYa/X njI9go/vXdx/GOQGHzKeQfC5WGYKzHet7+wE89n6uORqc6soo//r/DpC75u2CIH17nyS axtD86txzWDE1wpihQitq10h+5n7g60WJBQruqse1/WRb0EaUjfacgv2gMD58AW8H2Tj tJVBu9jNC8CTeC1oGyX+6VMXkMFouIvzDGPX+VbebzfY3NZI3DGCcASgnTeQbRposAXE qhSjI9n2jp+NgAIqR60M3s2itlSK1FE4EchK4+7+l4QDuDio5+U5Ls66CslzLLkOiep+ Z4tA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779693320; x=1780298120; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=47oa6+bWcTdZtRyJkBYrwULdTRG5mV9VUpeXnfu9Pl0=; b=THIV5jXxW+r0AzE7jlilePB7ENVVT4AGW/66AK6BPsALau1AVD8VkxqUs25W8ndkUi O6S517IKgYhkLr5N+pmELeUXuidzA8Ilo1gi7vZq4EuZB5UhhwiIm9322/meV0nFmM1w 3FZVgTvq/loHRfxxUKyagtG8heknN56lRZrpiGz0p+CB2RR41pdlDZ1DgHveHwadhej2 4q0LVE2QJXez1c+4cfKPzI0bwo0sywuXfZbjMfc7Kx43r4qc5rnHTErPQcBaQisiQCtJ zy90Wjrt1R0oWtxmIv3yONeeL1volQ7N6PO57R6zJOOgPlnsl/MDQ4s6fcnai6qPEccV vhew== X-Forwarded-Encrypted: i=1; AFNElJ+tsjUChe1Omh6i4jlIt0GnNZZm2zzseJVFXZ/Jx12lkZmjdxbylGwcLkOnOGVgDklJJNAM3/9Zmz7SnpU=@vger.kernel.org X-Gm-Message-State: AOJu0Yz26HKrAaKlCpBl83gRvzk+Afecta7Ckg2AUZE6pd6DXxFQ4jTd y+EM2wGmAqKhH4uoosZKzJ5GFl9tx/XSoA5CmjU6BqaLra4iY02QXFNS X-Gm-Gg: Acq92OGRn5SmxnXoefz2AWY6NXQXnL1KvhXwOipkz+u2yAk8bxHHc4av4A32O8D5ucp /KDbyHL3Z3cRsaAPvqH18htGWan5ndjdHnvgyEBlVhOBR5CA7oQZw4Jr2fQXOPfw7IJQa2PicMU /CKRTH08eqyjFeNrs4Z/Ni4+7hjaU0BWqiL5Jhl2GGp7fXWykhHqFTbmP4tIiBgO/VCozBTwdzL vZMdjWf4Q4KEzDHW5cefr3c/pRs7T32uCKouqJzvyUfnTAJNMEyiwoMbj4Dp/VfsX0dUi8LHgEx ubjUL37ZURENQpbPrv7ku8fBZZfzcvwaPBSNV4/AES4mj54+eLrj8yVLeljo/ADKazRIAzN3w2p hjJXNQzNN5TYxMuVS7Kw9j4Q8hwHKdObZ5wwFyE6tyCynjZXNZX3NqdwmpsGFUCfcRUXzMfo4Tr 0OBqNyUS925PSB04yD3cJM1rHkPFGYm9CqPw== X-Received: by 2002:a05:600c:3593:b0:488:8bdd:cfcc with SMTP id 5b1f17b1804b1-4904225ae0emr248431945e9.0.1779693319595; Mon, 25 May 2026 00:15:19 -0700 (PDT) Received: from localhost ([196.207.164.177]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49044f2bad3sm244022805e9.0.2026.05.25.00.15.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 May 2026 00:15:19 -0700 (PDT) Date: Mon, 25 May 2026 10:15:16 +0300 From: Dan Carpenter To: Bartosz Golaszewski Cc: Linus Walleij , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH] gpio: virtuser: Fix uninitialized data bug in gpio_virtuser_direction_do_write() Message-ID: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" If *ppos is non-zero then simple_write_to_buffer() won't initialize the start of the buffer. Really, non-zero values for *ppos aren't going to work at all. Check for that return -EINVAL at the start of the function. Fixes: 91581c4b3f29 ("gpio: virtuser: new virtual testing driver for the GP= IO API") Signed-off-by: Dan Carpenter --- drivers/gpio/gpio-virtuser.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpio/gpio-virtuser.c b/drivers/gpio/gpio-virtuser.c index 128520d340d4..846f8688fec5 100644 --- a/drivers/gpio/gpio-virtuser.c +++ b/drivers/gpio/gpio-virtuser.c @@ -397,7 +397,7 @@ static ssize_t gpio_virtuser_direction_do_write(struct = file *file, char buf[32], *trimmed; int ret, dir, val =3D 0; =20 - if (count >=3D sizeof(buf)) + if (*ppos !=3D 0 || count >=3D sizeof(buf)) return -EINVAL; =20 ret =3D simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, user_buf, coun= t); @@ -622,7 +622,7 @@ static ssize_t gpio_virtuser_consumer_write(struct file= *file, char buf[GPIO_VIRTUSER_NAME_BUF_LEN + 2]; int ret; =20 - if (count >=3D sizeof(buf)) + if (*ppos !=3D 0 || count >=3D sizeof(buf)) return -EINVAL; =20 ret =3D simple_write_to_buffer(buf, GPIO_VIRTUSER_NAME_BUF_LEN, ppos, --=20 2.53.0