From: Lloyd Atkinson <latkinso@codeaurora.org>
To: Rob Clark <robdclark@gmail.com>
Cc: linux-arm-msm <linux-arm-msm@vger.kernel.org>,
dri-devel <dri-devel@lists.freedesktop.org>
Subject: Re: [PATCH 3/3] drm/msm/dsi: check msm_dsi and dsi pointers before use
Date: Mon, 15 Jan 2018 10:01:45 -0500 [thread overview]
Message-ID: <00cdfe41-12fd-e57b-5166-b6236cf66d37@codeaurora.org> (raw)
In-Reply-To: <CAF6AEGtm0GgHBNGvT2GRRvs=mUvwbc8P1vWgxNLd5b0znw69rg@mail.gmail.com>
On 1/15/2018 9:48 AM, Rob Clark wrote:
> On Fri, Jan 12, 2018 at 3:55 PM, Lloyd Atkinson <latkinso@codeaurora.org> wrote:
>> Move null checks of pointer arguments to the beginning of the
>> modeset init function since they are referenced immediately
>> instead of after they have already been used.
>>
>> Signed-off-by: Lloyd Atkinson <latkinso@codeaurora.org>
>> ---
>> drivers/gpu/drm/msm/dsi/dsi.c | 22 ++++++++++------------
>> 1 file changed, 10 insertions(+), 12 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/msm/dsi/dsi.c b/drivers/gpu/drm/msm/dsi/dsi.c
>> index 98742d7..be855db 100644
>> --- a/drivers/gpu/drm/msm/dsi/dsi.c
>> +++ b/drivers/gpu/drm/msm/dsi/dsi.c
>> @@ -196,7 +196,7 @@ int msm_dsi_modeset_init(struct msm_dsi *msm_dsi, struct drm_device *dev,
>> struct drm_bridge *ext_bridge;
>> int ret;
>>
>> - if (WARN_ON(!encoder))
>> + if (!encoder || !msm_dsi || !dev)
>
> hmm, the checking if msm_dsi is null later in the fail: case is
> certainly sketchy after we've already deref'd it.. so this looks like
> the right thing. But I'd like to keep the WARN_ON(), since this is a
> case that shouldn't really happen. The WARN_ON() nicely documents
> that none of these parameters are expected to be NULL, and it gives a
> big shouty message to anyone who inadvertently changes something that
> breaks that assumption. Other than that, it looks good.
>
> BR,
> -R
Sure. Do you want to add WARN_ONs to msm_dsi and dev as well?
Thanks,
Lloyd
>
>
>> return -EINVAL;
>>
>> msm_dsi->dev = dev;
>> @@ -245,19 +245,17 @@ int msm_dsi_modeset_init(struct msm_dsi *msm_dsi, struct drm_device *dev,
>>
>> return 0;
>> fail:
>> - if (msm_dsi) {
>> - /* bridge/connector are normally destroyed by drm: */
>> - if (msm_dsi->bridge) {
>> - msm_dsi_manager_bridge_destroy(msm_dsi->bridge);
>> - msm_dsi->bridge = NULL;
>> - }
>> + /* bridge/connector are normally destroyed by drm: */
>> + if (msm_dsi->bridge) {
>> + msm_dsi_manager_bridge_destroy(msm_dsi->bridge);
>> + msm_dsi->bridge = NULL;
>> + }
>>
>> - /* don't destroy connector if we didn't make it */
>> - if (msm_dsi->connector && !msm_dsi->external_bridge)
>> - msm_dsi->connector->funcs->destroy(msm_dsi->connector);
>> + /* don't destroy connector if we didn't make it */
>> + if (msm_dsi->connector && !msm_dsi->external_bridge)
>> + msm_dsi->connector->funcs->destroy(msm_dsi->connector);
>>
>> - msm_dsi->connector = NULL;
>> - }
>> + msm_dsi->connector = NULL;
>>
>> return ret;
>> }
>> --
>> QUALCOMM Canada, on behalf of Qualcomm Innovation Center, Inc. is a member
>> of Code Aurora Forum, hosted by The Linux Foundation
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
QUALCOMM Canada, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2018-01-15 15:01 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-12 20:55 [PATCH 0/3] drm/msm/dsi: improve pointer validation checks Lloyd Atkinson
2018-01-12 20:55 ` [PATCH 1/3] drm/msm/dsi: check src_pll for null in dsi manager Lloyd Atkinson
2018-01-15 14:40 ` Rob Clark
2018-01-12 20:55 ` [PATCH 2/3] drm/msm/dsi: correct DSI id bounds check during registration Lloyd Atkinson
2018-01-15 14:44 ` Rob Clark
2018-01-12 20:55 ` [PATCH 3/3] drm/msm/dsi: check msm_dsi and dsi pointers before use Lloyd Atkinson
2018-01-15 14:48 ` Rob Clark
2018-01-15 15:01 ` Lloyd Atkinson [this message]
2018-01-15 15:25 ` Rob Clark
2018-01-16 21:26 ` [PATCH v2 0/3] drm/msm/dsi: improve pointer validation checks Lloyd Atkinson
2018-01-16 21:26 ` [PATCH v2 1/3] drm/msm/dsi: check for failure on retrieving pll in dsi manager Lloyd Atkinson
2018-01-16 21:26 ` [PATCH v2 2/3] drm/msm/dsi: correct DSI id bounds check during registration Lloyd Atkinson
2018-01-16 21:26 ` [PATCH v2 3/3] drm/msm/dsi: check msm_dsi and dsi pointers before use Lloyd Atkinson
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=00cdfe41-12fd-e57b-5166-b6236cf66d37@codeaurora.org \
--to=latkinso@codeaurora.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=robdclark@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.