linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Gabriel Knezek <gabeknez@linux.microsoft.com>
To: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org,
	bgolaszewski@baylibre.com, linus.walleij@linaro.org,
	joe.reviewer@hotmail.com
Cc: Gabriel Knezek <gabeknez@linux.microsoft.com>
Subject: [PATCH v3] gpiolib: cdev: zero padding during conversion to gpioline_info_changed
Date: Mon, 21 Jun 2021 15:28:59 -0700	[thread overview]
Message-ID: <1624314539-17396-1-git-send-email-gabeknez@linux.microsoft.com> (raw)

When userspace requests a GPIO v1 line info changed event,
lineinfo_watch_read() populates and returns the gpioline_info_changed
structure. It contains 5 words of padding at the end which are not
initialized before being returned to userspace.

Zero the structure in gpio_v2_line_info_change_to_v1() before populating
its contents.

Fixes: aad955842d1c ("gpiolib: cdev: support GPIO_V2_GET_LINEINFO_IOCTL and
GPIO_V2_GET_LINEINFO_WATCH_IOCTL")
Signed-off-by: Gabriel Knezek <gabeknez@linux.microsoft.com>
---
Changes in v3:
  - Include the Fixes tag referencing the code being fixed and properly
    version the patch.

Changes in v2:
  - Update commit message and subject with suggestions about clarity.
  - Patch series at https://www.spinics.net/lists/linux-gpio/msg62163.html

v1:
  - Initial patch
  - Patch series at https://www.spinics.net/lists/linux-gpio/msg62084.html

 drivers/gpio/gpiolib-cdev.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpio/gpiolib-cdev.c b/drivers/gpio/gpiolib-cdev.c
index ee5903aac497..af68532835fe 100644
--- a/drivers/gpio/gpiolib-cdev.c
+++ b/drivers/gpio/gpiolib-cdev.c
@@ -1865,6 +1865,7 @@ static void gpio_v2_line_info_changed_to_v1(
 		struct gpio_v2_line_info_changed *lic_v2,
 		struct gpioline_info_changed *lic_v1)
 {
+	memset(lic_v1, 0, sizeof(*lic_v1));
 	gpio_v2_line_info_to_v1(&lic_v2->info, &lic_v1->info);
 	lic_v1->timestamp = lic_v2->timestamp_ns;
 	lic_v1->event_type = lic_v2->event_type;
-- 
2.25.1


             reply	other threads:[~2021-06-21 22:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-21 22:28 Gabriel Knezek [this message]
2021-06-22  2:06 ` [PATCH v3] gpiolib: cdev: zero padding during conversion to gpioline_info_changed Kent Gibson
2021-06-22  2:42   ` Kent Gibson
2021-06-22  7:55 ` Bartosz Golaszewski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1624314539-17396-1-git-send-email-gabeknez@linux.microsoft.com \
    --to=gabeknez@linux.microsoft.com \
    --cc=bgolaszewski@baylibre.com \
    --cc=joe.reviewer@hotmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).