Message ID | 20250223201709.4917-1-jiashengjiangcool@gmail.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | dpll: Add a check before kfree() to match the existing check before kmemdup() | expand |
diff --git a/drivers/dpll/dpll_core.c b/drivers/dpll/dpll_core.c index 32019dc33cca..7d147adf8455 100644 --- a/drivers/dpll/dpll_core.c +++ b/drivers/dpll/dpll_core.c @@ -475,7 +475,8 @@ static int dpll_pin_prop_dup(const struct dpll_pin_properties *src, err_panel_label: kfree(dst->board_label); err_board_label: - kfree(dst->freq_supported); + if (src->freq_supported_num) + kfree(dst->freq_supported); return -ENOMEM; }
When src->freq_supported is not NULL but src->freq_supported_num is 0, dst->freq_supported is equal to src->freq_supported. In this case, if the subsequent kstrdup() fails, src->freq_supported may be freed without being set to NULL, potentially leading to a use-after-free or double-free error. Fixes: 830ead5fb0c5 ("dpll: fix pin dump crash for rebound module") Cc: <stable@vger.kernel.org> # v6.8+ Signed-off-by: Jiasheng Jiang <jiashengjiangcool@gmail.com> --- drivers/dpll/dpll_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)