Skip to content

Commit 7455b70

Browse files
ConchuODbebarino
authored andcommitted
clk: microchip: fix potential UAF in auxdev release callback
Similar to commit 1c11289 ("peci: cpu: Fix use-after-free in adev_release()"), the auxiliary device is not torn down in the correct order. If auxiliary_device_add() fails, the release callback will be called twice, resulting in a UAF. Due to timing, the auxdev code in this driver "took inspiration" from the aforementioned commit, and thus its bugs too! Moving auxiliary_device_uninit() to the unregister callback instead avoids the issue. CC: stable@vger.kernel.org Fixes: b56bae2 ("clk: microchip: mpfs: add reset controller") Signed-off-by: Conor Dooley <conor.dooley@microchip.com> Link: https://lore.kernel.org/r/20230413-critter-synopsis-dac070a86cb4@spud Signed-off-by: Stephen Boyd <sboyd@kernel.org>
1 parent fb8b9d2 commit 7455b70

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

drivers/clk/microchip/clk-mpfs.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,14 +374,13 @@ static void mpfs_reset_unregister_adev(void *_adev)
374374
struct auxiliary_device *adev = _adev;
375375

376376
auxiliary_device_delete(adev);
377+
auxiliary_device_uninit(adev);
377378
}
378379

379380
static void mpfs_reset_adev_release(struct device *dev)
380381
{
381382
struct auxiliary_device *adev = to_auxiliary_dev(dev);
382383

383-
auxiliary_device_uninit(adev);
384-
385384
kfree(adev);
386385
}
387386

0 commit comments

Comments
 (0)