All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bartosz Golaszewski <brgl@bgdev.pl>
To: Kent Gibson <warthog618@gmail.com>
Cc: "open list:GPIO SUBSYSTEM" <linux-gpio@vger.kernel.org>,
	Bartosz Golaszewski <bgolaszewski@baylibre.com>,
	Pedro Botella <pbotella@gmail.com>
Subject: Re: [lingpiod][PATCH] bindings: python: fix uninitialized default_vals being passed to gpiod_LineBulk_request()
Date: Mon, 15 Feb 2021 16:48:34 +0100	[thread overview]
Message-ID: <CAMRc=Mc8Dt12j0ymYdjOkCdvCB4X_UGq+7n4NvAwZKwVJp5mMg@mail.gmail.com> (raw)
In-Reply-To: <20210215124831.60707-1-warthog618@gmail.com>

On Mon, Feb 15, 2021 at 1:51 PM Kent Gibson <warthog618@gmail.com> wrote:
>
> If "default_vals" is not provided in the kwds then default_vals are
> passed uninitialized to gpiod_line_request_bulk(), so rename the
> existing default_vals to vals and introduce a new default_vals that
> points to vals, or NULL if no defaults have been passed.
>
> Fixes: 96c524c4951c (bindings: implement python bindings)
> Reported-by: Pedro Botella <pbotella@gmail.com>
> Signed-off-by: Kent Gibson <warthog618@gmail.com>
> ---
>  bindings/python/gpiodmodule.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/bindings/python/gpiodmodule.c b/bindings/python/gpiodmodule.c
> index fee4c32..832787d 100644
> --- a/bindings/python/gpiodmodule.c
> +++ b/bindings/python/gpiodmodule.c
> @@ -1327,12 +1327,13 @@ static PyObject *gpiod_LineBulk_request(gpiod_LineBulkObject *self,
>                                   NULL };
>
>         int rv, type = gpiod_LINE_REQ_DIR_AS_IS, flags = 0,
> -           default_vals[GPIOD_LINE_BULK_MAX_LINES], val;
> +           vals[GPIOD_LINE_BULK_MAX_LINES], val;
>         PyObject *def_vals_obj = NULL, *iter, *next;
>         struct gpiod_line_request_config conf;
>         struct gpiod_line_bulk bulk;
>         Py_ssize_t num_def_vals;
>         char *consumer = NULL;
> +       const int *default_vals = NULL;
>         Py_ssize_t i;
>
>         if (gpiod_LineBulkOwnerIsClosed(self))
> @@ -1348,7 +1349,7 @@ static PyObject *gpiod_LineBulk_request(gpiod_LineBulkObject *self,
>         gpiod_MakeRequestConfig(&conf, consumer, type, flags);
>
>         if (def_vals_obj) {
> -               memset(default_vals, 0, sizeof(default_vals));
> +               memset(vals, 0, sizeof(vals));
>
>                 num_def_vals = PyObject_Size(def_vals_obj);
>                 if (num_def_vals != self->num_lines) {
> @@ -1375,8 +1376,9 @@ static PyObject *gpiod_LineBulk_request(gpiod_LineBulkObject *self,
>                                 return NULL;
>                         }
>
> -                       default_vals[i] = !!val;
> +                       vals[i] = !!val;
>                 }
> +               default_vals = vals;
>         }
>
>         Py_BEGIN_ALLOW_THREADS;
> --
> 2.30.0
>

Applied, thanks!

Bartosz

      reply	other threads:[~2021-02-15 16:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-15 12:48 [lingpiod][PATCH] bindings: python: fix uninitialized default_vals being passed to gpiod_LineBulk_request() Kent Gibson
2021-02-15 15:48 ` Bartosz Golaszewski [this message]

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='CAMRc=Mc8Dt12j0ymYdjOkCdvCB4X_UGq+7n4NvAwZKwVJp5mMg@mail.gmail.com' \
    --to=brgl@bgdev.pl \
    --cc=bgolaszewski@baylibre.com \
    --cc=linux-gpio@vger.kernel.org \
    --cc=pbotella@gmail.com \
    --cc=warthog618@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.