Commit ae11f04
usb: typec: tcpm: Check for port partner validity before consuming it
typec_register_partner() does not guarantee partner registration
to always succeed. In the event of failure, port->partner is set
to the error value or NULL. Given that port->partner validity is
not checked, this results in the following crash:
Unable to handle kernel NULL pointer dereference at virtual address xx
pc : run_state_machine+0x1bc8/0x1c08
lr : run_state_machine+0x1b90/0x1c08
..
Call trace:
run_state_machine+0x1bc8/0x1c08
tcpm_state_machine_work+0x94/0xe4
kthread_worker_fn+0x118/0x328
kthread+0x1d0/0x23c
ret_from_fork+0x10/0x20
To prevent the crash, check for port->partner validity before
derefencing it in all the call sites.
Cc: stable@vger.kernel.org
Fixes: c97cd0b ("usb: typec: tcpm: set initial svdm version based on pd revision")
Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://lore.kernel.org/r/20240427202812.3435268-1-badhri@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>1 parent cdc9946 commit ae11f04
1 file changed
+23
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1584 | 1584 | | |
1585 | 1585 | | |
1586 | 1586 | | |
1587 | | - | |
| 1587 | + | |
| 1588 | + | |
1588 | 1589 | | |
1589 | 1590 | | |
1590 | 1591 | | |
| |||
1746 | 1747 | | |
1747 | 1748 | | |
1748 | 1749 | | |
| 1750 | + | |
| 1751 | + | |
| 1752 | + | |
1749 | 1753 | | |
1750 | 1754 | | |
1751 | 1755 | | |
| |||
4238 | 4242 | | |
4239 | 4243 | | |
4240 | 4244 | | |
| 4245 | + | |
| 4246 | + | |
4241 | 4247 | | |
| 4248 | + | |
4242 | 4249 | | |
4243 | 4250 | | |
4244 | 4251 | | |
| |||
4248 | 4255 | | |
4249 | 4256 | | |
4250 | 4257 | | |
4251 | | - | |
4252 | | - | |
4253 | | - | |
| 4258 | + | |
| 4259 | + | |
| 4260 | + | |
| 4261 | + | |
| 4262 | + | |
| 4263 | + | |
| 4264 | + | |
4254 | 4265 | | |
4255 | 4266 | | |
4256 | 4267 | | |
| |||
4330 | 4341 | | |
4331 | 4342 | | |
4332 | 4343 | | |
4333 | | - | |
4334 | | - | |
4335 | | - | |
| 4344 | + | |
| 4345 | + | |
| 4346 | + | |
| 4347 | + | |
| 4348 | + | |
4336 | 4349 | | |
4337 | 4350 | | |
4338 | 4351 | | |
| |||
4556 | 4569 | | |
4557 | 4570 | | |
4558 | 4571 | | |
| 4572 | + | |
| 4573 | + | |
| 4574 | + | |
4559 | 4575 | | |
4560 | 4576 | | |
4561 | 4577 | | |
| |||
0 commit comments