From: Boris Brezillon <boris.brezillon@collabora.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@linux.ie>, Daniel Vetter <daniel@ffwll.ch>,
Jernej Skrabec <jernej.skrabec@gmail.com>,
Neil Armstrong <narmstrong@baylibre.com>,
dri-devel@lists.freedesktop.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] drm/bridge: Avoid uninitialized variable warning
Date: Tue, 28 Jun 2022 09:26:09 +0200 [thread overview]
Message-ID: <20220628092609.7d0b1ea3@collabora.com> (raw)
In-Reply-To: <Yrqm5yYVa6xMY2vq@kili>
On Tue, 28 Jun 2022 09:59:51 +0300
Dan Carpenter <dan.carpenter@oracle.com> wrote:
> This works, but technically it uses "num_in_bus_fmts" before it has been
> initialized so it leads to static checker warnings and probably KMEMsan
> warnings at run time. Reverse the checks so it checks for failure first
> and then check for unsupported formats next.
>
> Fixes: f32df58acc68 ("drm/bridge: Add the necessary bits to support bus format negotiation")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> drivers/gpu/drm/drm_bridge.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
> index e275b4ca344b..00cbde654472 100644
> --- a/drivers/gpu/drm/drm_bridge.c
> +++ b/drivers/gpu/drm/drm_bridge.c
> @@ -897,10 +897,10 @@ static int select_bus_fmt_recursive(struct drm_bridge *first_bridge,
> conn_state,
> out_bus_fmt,
> &num_in_bus_fmts);
> - if (!num_in_bus_fmts)
> - return -ENOTSUPP;
> - else if (!in_bus_fmts)
> + if (!in_bus_fmts)
> return -ENOMEM;
> + else if (!num_in_bus_fmts)
> + return -ENOTSUPP;
Well, it changes the error we return when num_in_bus_fmts = 0
&& in_bus_fmts == NULL which is not an ENOMEM situation, so I'd rather
initialize num_{in,out}_bus_fmts to 0 here.
>
> if (first_bridge == cur_bridge) {
> cur_state->input_bus_cfg.format = in_bus_fmts[0];
> @@ -993,10 +993,10 @@ drm_atomic_bridge_chain_select_bus_fmts(struct drm_bridge *bridge,
> crtc_state,
> conn_state,
> &num_out_bus_fmts);
> - if (!num_out_bus_fmts)
> - return -ENOTSUPP;
> - else if (!out_bus_fmts)
> + if (!out_bus_fmts)
> return -ENOMEM;
> + else if (!num_out_bus_fmts)
> + return -ENOTSUPP;
> } else {
> num_out_bus_fmts = 1;
> out_bus_fmts = kmalloc(sizeof(*out_bus_fmts), GFP_KERNEL);
WARNING: multiple messages have this Message-ID (diff)
From: Boris Brezillon <boris.brezillon@collabora.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Thomas Zimmermann <tzimmermann@suse.de>,
Neil Armstrong <narmstrong@baylibre.com>,
David Airlie <airlied@linux.ie>,
kernel-janitors@vger.kernel.org, dri-devel@lists.freedesktop.org,
Jernej Skrabec <jernej.skrabec@gmail.com>
Subject: Re: [PATCH] drm/bridge: Avoid uninitialized variable warning
Date: Tue, 28 Jun 2022 09:26:09 +0200 [thread overview]
Message-ID: <20220628092609.7d0b1ea3@collabora.com> (raw)
In-Reply-To: <Yrqm5yYVa6xMY2vq@kili>
On Tue, 28 Jun 2022 09:59:51 +0300
Dan Carpenter <dan.carpenter@oracle.com> wrote:
> This works, but technically it uses "num_in_bus_fmts" before it has been
> initialized so it leads to static checker warnings and probably KMEMsan
> warnings at run time. Reverse the checks so it checks for failure first
> and then check for unsupported formats next.
>
> Fixes: f32df58acc68 ("drm/bridge: Add the necessary bits to support bus format negotiation")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> drivers/gpu/drm/drm_bridge.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
> index e275b4ca344b..00cbde654472 100644
> --- a/drivers/gpu/drm/drm_bridge.c
> +++ b/drivers/gpu/drm/drm_bridge.c
> @@ -897,10 +897,10 @@ static int select_bus_fmt_recursive(struct drm_bridge *first_bridge,
> conn_state,
> out_bus_fmt,
> &num_in_bus_fmts);
> - if (!num_in_bus_fmts)
> - return -ENOTSUPP;
> - else if (!in_bus_fmts)
> + if (!in_bus_fmts)
> return -ENOMEM;
> + else if (!num_in_bus_fmts)
> + return -ENOTSUPP;
Well, it changes the error we return when num_in_bus_fmts = 0
&& in_bus_fmts == NULL which is not an ENOMEM situation, so I'd rather
initialize num_{in,out}_bus_fmts to 0 here.
>
> if (first_bridge == cur_bridge) {
> cur_state->input_bus_cfg.format = in_bus_fmts[0];
> @@ -993,10 +993,10 @@ drm_atomic_bridge_chain_select_bus_fmts(struct drm_bridge *bridge,
> crtc_state,
> conn_state,
> &num_out_bus_fmts);
> - if (!num_out_bus_fmts)
> - return -ENOTSUPP;
> - else if (!out_bus_fmts)
> + if (!out_bus_fmts)
> return -ENOMEM;
> + else if (!num_out_bus_fmts)
> + return -ENOTSUPP;
> } else {
> num_out_bus_fmts = 1;
> out_bus_fmts = kmalloc(sizeof(*out_bus_fmts), GFP_KERNEL);
next prev parent reply other threads:[~2022-06-28 7:26 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-28 6:59 [PATCH] drm/bridge: Avoid uninitialized variable warning Dan Carpenter
2022-06-28 6:59 ` Dan Carpenter
2022-06-28 7:26 ` Boris Brezillon [this message]
2022-06-28 7:26 ` Boris Brezillon
2022-06-28 7:45 ` Dan Carpenter
2022-06-28 7:45 ` Dan Carpenter
2022-06-28 8:54 ` Boris Brezillon
2022-06-28 8:54 ` Boris Brezillon
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=20220628092609.7d0b1ea3@collabora.com \
--to=boris.brezillon@collabora.com \
--cc=airlied@linux.ie \
--cc=dan.carpenter@oracle.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=jernej.skrabec@gmail.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=narmstrong@baylibre.com \
--cc=tzimmermann@suse.de \
/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.