dpll: fix pin dump crash for rebound module
authorArkadiusz Kubalewski <arkadiusz.kubalewski@intel.com>
Fri, 19 Jan 2024 13:43:02 +0000 (14:43 +0100)
committerDavid S. Miller <davem@davemloft.net>
Mon, 22 Jan 2024 11:01:11 +0000 (11:01 +0000)
commit830ead5fb0c5855ce4d70ba2ed4a673b5f1e7d9b
tree84b109b227b86b01d75dec6486992441da00bd5f
parentb6a11a7fc4d6337f7ea720b9287d1b9749c4eae0
dpll: fix pin dump crash for rebound module

When a kernel module is unbound but the pin resources were not entirely
freed (other kernel module instance of the same PCI device have had kept
the reference to that pin), and kernel module is again bound, the pin
properties would not be updated (the properties are only assigned when
memory for the pin is allocated), prop pointer still points to the
kernel module memory of the kernel module which was deallocated on the
unbind.

If the pin dump is invoked in this state, the result is a kernel crash.
Prevent the crash by storing persistent pin properties in dpll subsystem,
copy the content from the kernel module when pin is allocated, instead of
using memory of the kernel module.

Fixes: 9431063ad323 ("dpll: core: Add DPLL framework base functions")
Fixes: 9d71b54b65b1 ("dpll: netlink: Add DPLL framework base functions")
Reviewed-by: Jan Glaza <jan.glaza@intel.com>
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Signed-off-by: Arkadiusz Kubalewski <arkadiusz.kubalewski@intel.com>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/dpll/dpll_core.c
drivers/dpll/dpll_core.h
drivers/dpll/dpll_netlink.c