Commit 0482c34
usb: ucsi: Fix ucsi->connector race
ucsi_init() which runs from a workqueue sets ucsi->connector and
on an error will clear it again.
ucsi->connector gets dereferenced by ucsi_resume(), this checks for
ucsi->connector being NULL in case ucsi_init() has not finished yet;
or in case ucsi_init() has failed.
ucsi_init() setting ucsi->connector and then clearing it again on
an error creates a race where the check in ucsi_resume() may pass,
only to have ucsi->connector free-ed underneath it when ucsi_init()
hits an error.
Fix this race by making ucsi_init() store the connector array in
a local variable and only assign it to ucsi->connector on success.
Fixes: bdc62f2 ("usb: typec: ucsi: Simplified registration and I/O API")
Cc: stable@vger.kernel.org
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20230308154244.722337-3-hdegoede@redhat.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>1 parent f87fb98 commit 0482c34
1 file changed
Lines changed: 9 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1125 | 1125 | | |
1126 | 1126 | | |
1127 | 1127 | | |
1128 | | - | |
| 1128 | + | |
1129 | 1129 | | |
1130 | 1130 | | |
1131 | 1131 | | |
1132 | 1132 | | |
1133 | | - | |
1134 | 1133 | | |
1135 | 1134 | | |
1136 | 1135 | | |
| |||
1151 | 1150 | | |
1152 | 1151 | | |
1153 | 1152 | | |
1154 | | - | |
1155 | 1153 | | |
1156 | 1154 | | |
1157 | 1155 | | |
| |||
1328 | 1326 | | |
1329 | 1327 | | |
1330 | 1328 | | |
1331 | | - | |
| 1329 | + | |
1332 | 1330 | | |
1333 | 1331 | | |
1334 | 1332 | | |
| |||
1359 | 1357 | | |
1360 | 1358 | | |
1361 | 1359 | | |
1362 | | - | |
1363 | | - | |
1364 | | - | |
| 1360 | + | |
| 1361 | + | |
1365 | 1362 | | |
1366 | 1363 | | |
1367 | 1364 | | |
1368 | 1365 | | |
1369 | 1366 | | |
1370 | 1367 | | |
1371 | | - | |
| 1368 | + | |
| 1369 | + | |
1372 | 1370 | | |
1373 | 1371 | | |
1374 | 1372 | | |
| |||
1380 | 1378 | | |
1381 | 1379 | | |
1382 | 1380 | | |
| 1381 | + | |
1383 | 1382 | | |
1384 | 1383 | | |
1385 | 1384 | | |
1386 | 1385 | | |
1387 | | - | |
| 1386 | + | |
1388 | 1387 | | |
1389 | 1388 | | |
1390 | 1389 | | |
| |||
1400 | 1399 | | |
1401 | 1400 | | |
1402 | 1401 | | |
1403 | | - | |
1404 | | - | |
1405 | | - | |
1406 | | - | |
| 1402 | + | |
1407 | 1403 | | |
1408 | 1404 | | |
1409 | 1405 | | |
| |||
0 commit comments