From: Sergei Shtylyov <sergei.shtylyov@gmail.com>
To: Biju Das <biju.das.jz@bp.renesas.com>,
Heikki Krogerus <heikki.krogerus@linux.intel.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Biju Das <biju.das@bp.renesas.com>,
linux-usb@vger.kernel.org,
Geert Uytterhoeven <geert+renesas@glider.be>,
Fabrizio Castro <fabrizio.castro.jz@renesas.com>,
linux-renesas-soc@vger.kernel.org
Subject: Re: [PATCH 2/4] usb: typec: hd3ss3220: Fix NULL pointer crash
Date: Thu, 15 Dec 2022 12:56:39 +0300 [thread overview]
Message-ID: <6408543e-29ac-ecae-b871-8ab9349cd0f5@gmail.com> (raw)
In-Reply-To: <20221209155623.29147-3-biju.das.jz@bp.renesas.com>
Hello!
On 12/9/22 6:56 PM, Biju Das wrote:
> The value returned by usb_role_switch_get() can be NULL and it leads
> to NULL pointer crash. This patch fixes this issue by adding NULL
> check for the role switch handle.
>
> [ 25.336613] Hardware name: Silicon Linux RZ/G2E evaluation kit EK874 (CAT874 + CAT875) (DT)
> [ 25.344991] Workqueue: events_unbound deferred_probe_work_func
> [ 25.350869] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
> [ 25.357854] pc : renesas_usb3_role_switch_get+0x40/0x80 [renesas_usb3]
> [ 25.364428] lr : renesas_usb3_role_switch_get+0x24/0x80 [renesas_usb3]
> [ 25.370986] sp : ffff80000a4b3a40
> [ 25.374311] x29: ffff80000a4b3a40 x28: 0000000000000000 x27: 0000000000000000
> [ 25.381476] x26: ffff80000a3ade78 x25: ffff00000a809005 x24: ffff80000117f178
> [ 25.388641] x23: ffff00000a8d7810 x22: ffff00000a8d8410 x21: 0000000000000000
> [ 25.395805] x20: ffff000011cd7080 x19: ffff000011cd7080 x18: 0000000000000020
> [ 25.402969] x17: ffff800076196000 x16: ffff800008004000 x15: 0000000000004000
> [ 25.410133] x14: 000000000000022b x13: 0000000000000001 x12: 0000000000000001
> [ 25.417291] x11: 0000000000000000 x10: 0000000000000a40 x9 : ffff80000a4b3770
> [ 25.424452] x8 : ffff00007fbc9000 x7 : 0040000000000008 x6 : ffff00000a8d8590
> [ 25.431615] x5 : ffff80000a4b3960 x4 : 0000000000000000 x3 : ffff00000a8d84f4
> [ 25.438776] x2 : 0000000000000218 x1 : ffff80000a715218 x0 : 0000000000000218
> [ 25.445942] Call trace:
> [ 25.448398] renesas_usb3_role_switch_get+0x40/0x80 [renesas_usb3]
> [ 25.454613] renesas_usb3_role_switch_set+0x4c/0x440 [renesas_usb3]
> [ 25.460908] usb_role_switch_set_role+0x44/0xa4
> [ 25.465468] hd3ss3220_set_role+0xa0/0x100 [hd3ss3220]
> [ 25.470635] hd3ss3220_probe+0x118/0x2fc [hd3ss3220]
> [ 25.475621] i2c_device_probe+0x338/0x384
>
> Fixes: 5a9a8a4c5058 ("usb: typec: hd3ss3220: hd3ss3220_probe() warn: passing zero to 'PTR_ERR'")
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> ---
> This issue triggered on RZ/G2E board, where there is no USB3 firmware and it
> returned a null role switch handle.
> ---
> drivers/usb/typec/hd3ss3220.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/typec/hd3ss3220.c b/drivers/usb/typec/hd3ss3220.c
> index 2a58185fb14c..c24bbccd14f9 100644
> --- a/drivers/usb/typec/hd3ss3220.c
> +++ b/drivers/usb/typec/hd3ss3220.c
> @@ -186,7 +186,10 @@ static int hd3ss3220_probe(struct i2c_client *client,
> hd3ss3220->role_sw = usb_role_switch_get(hd3ss3220->dev);
> }
>
> - if (IS_ERR(hd3ss3220->role_sw)) {
> + if (!hd3ss3220->role_sw) {
> + ret = -ENODEV;
> + goto err_put_fwnode;
> + } else if (IS_ERR(hd3ss3220->role_sw)) {
No need for *else* after *goto*.
[...]
MBR, Sergey
next prev parent reply other threads:[~2022-12-15 9:56 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-09 15:56 [PATCH 0/4] Add Polling support for role detection with HD3SS3220 Biju Das
2022-12-09 15:56 ` [PATCH 1/4] dt-bindings: usb: ti,hd3ss3220: Update interrupt property as optional Biju Das
2022-12-09 15:56 ` [PATCH 2/4] usb: typec: hd3ss3220: Fix NULL pointer crash Biju Das
2022-12-09 16:17 ` Greg Kroah-Hartman
2022-12-09 16:50 ` Biju Das
2022-12-15 9:56 ` Sergei Shtylyov [this message]
2022-12-09 15:56 ` [PATCH 3/4] usb: typec: hd3ss3220: Sort header files Biju Das
2022-12-09 16:16 ` Greg Kroah-Hartman
2022-12-09 16:49 ` Biju Das
2022-12-15 10:05 ` Geert Uytterhoeven
2022-12-15 11:44 ` Greg Kroah-Hartman
2022-12-09 15:56 ` [PATCH 4/4] usb: typec: hd3ss3220: Add polling support Biju Das
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=6408543e-29ac-ecae-b871-8ab9349cd0f5@gmail.com \
--to=sergei.shtylyov@gmail.com \
--cc=biju.das.jz@bp.renesas.com \
--cc=biju.das@bp.renesas.com \
--cc=fabrizio.castro.jz@renesas.com \
--cc=geert+renesas@glider.be \
--cc=gregkh@linuxfoundation.org \
--cc=heikki.krogerus@linux.intel.com \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=linux-usb@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