From: Greg KH <gregkh@linuxfoundation.org>
To: Dmitry Antipov <dmantipov@yandex.ru>
Cc: Michael Jamet <michael.jamet@intel.com>,
linux-usb@vger.kernel.org, lvc-project@linuxtesting.org
Subject: Re: [PATCH] thunderbolt: handle possible NULL pointer from get_device()
Date: Fri, 9 Jun 2023 08:30:54 +0200 [thread overview]
Message-ID: <2023060911-expose-unplanned-964a@gregkh> (raw)
In-Reply-To: <20230609061619.57756-1-dmantipov@yandex.ru>
On Fri, Jun 09, 2023 at 09:16:19AM +0300, Dmitry Antipov wrote:
> Handle possible NULL pointer returned by 'get_device()'
> in 'tb_xdomain_alloc()' and 'remove_unplugged_switch()'.
Sorry, but how can that happen?
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
> ---
> drivers/thunderbolt/icm.c | 5 +++++
> drivers/thunderbolt/xdomain.c | 4 ++++
> 2 files changed, 9 insertions(+)
>
> diff --git a/drivers/thunderbolt/icm.c b/drivers/thunderbolt/icm.c
> index 86521ebb2579..40ab6104a437 100644
> --- a/drivers/thunderbolt/icm.c
> +++ b/drivers/thunderbolt/icm.c
> @@ -2035,6 +2035,11 @@ static void remove_unplugged_switch(struct tb_switch *sw)
> {
> struct device *parent = get_device(sw->dev.parent);
>
> + if (!parent) {
This will never fail, how did you test this?
> + tb_warn(sw->tb, "no parent of switch %pUb\n", sw->uuid);
> + return;
> + }
> +
> pm_runtime_get_sync(parent);
>
> /*
> diff --git a/drivers/thunderbolt/xdomain.c b/drivers/thunderbolt/xdomain.c
> index e2b54887d331..a0ee683d752e 100644
> --- a/drivers/thunderbolt/xdomain.c
> +++ b/drivers/thunderbolt/xdomain.c
> @@ -1883,6 +1883,8 @@ struct tb_xdomain *tb_xdomain_alloc(struct tb *tb, struct device *parent,
>
> device_initialize(&xd->dev);
> xd->dev.parent = get_device(parent);
> + if (!xd->dev.parent)
Again, how did you test this? How can that ever happen?
thanks,
greg k-h
next prev parent reply other threads:[~2023-06-09 6:31 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-09 6:16 [PATCH] thunderbolt: handle possible NULL pointer from get_device() Dmitry Antipov
2023-06-09 6:30 ` Greg KH [this message]
2023-06-09 7:15 ` Dmitry Antipov
2023-06-09 7:46 ` Greg KH
2023-06-09 8:05 ` Dmitry Antipov
2023-06-09 8:20 ` Greg KH
2023-06-09 9:19 ` Dmitry Antipov
2023-06-09 9:30 ` Greg KH
2023-06-09 8:32 ` [lvc-project] " Alexey Khoroshilov
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=2023060911-expose-unplanned-964a@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=dmantipov@yandex.ru \
--cc=linux-usb@vger.kernel.org \
--cc=lvc-project@linuxtesting.org \
--cc=michael.jamet@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox