When booting top-of-tree the following WARN_ON triggers in the kernel on
a 15h AMD system.
WARNING: CPU: 2 PID: 621 at drivers/base/dd.c:349 driver_probe_device+0x38c
Modules linked in: i2c_amd756(+) amd_rng sg pcspkr parport_pc(+) parport k8
CPU: 2 PID: 621 Comm: systemd-udevd Not tainted 4.11.0-0.rc1.git0.1.el7_UNS
Hardware name: To Be Filled By O.E.M. To Be Filled By O.E.M./TYAN High-End
There are PCI devices that contain both a RNG and SMBUS device. The
RNG device is initialized by the amd-rng driver but the driver does not
register against the device. The SMBUS device is initialized by the
i2c-amd756 driver and registers against the device and hits the WARN_ON()
because the amd-rng driver has already allocated resources against the
The amd-rng driver was incorrectly migrated to the device resource model
(devres), and after code inspection I found that the geode-rng driver was also
incorrectly migrated. These drivers are using devres but do not register a
driver against the device, and both drivers are expecting a memory cleanup on
a driver detach that will never happen. This results in a memory leak when the
driver is unloaded and the inability to reload the driver.
Revert 31b2a73c9c5f ("hwrng: amd - Migrate to managed API"), and 6e9b5e76882c
("hwrng: geode - Migrate to managed API").
Signed-off-by: Prarit Bhargava <pra...@redhat.com>
Fixes: 31b2a73c9c5f ("hwrng: amd - Migrate to managed API").
Fixes: 6e9b5e76882c ("hwrng: geode - Migrate to managed API")
Cc: Matt Mackall <m...@selenic.com>
Cc: Herbert Xu <herb...@gondor.apana.org.au>
Cc: Corentin LABBE <clabbe.montj...@gmail.com>
Cc: PrasannaKumar Muralidharan <prasannatsmku...@gmail.com>
Cc: Wei Yongjun <weiyongj...@huawei.com>
Prarit Bhargava (2):
hwrng: amd - Revert managed API changes
hwrng: geode - Revert managed API changes
drivers/char/hw_random/amd-rng.c | 42 ++++++++++++++++++++++++------
drivers/char/hw_random/geode-rng.c | 50 +++++++++++++++++++++++++-----------
2 files changed, 69 insertions(+), 23 deletions(-)