]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
dpll: Add an assertion to check freq_supported_num
authorJiasheng Jiang <jiashengjiangcool@gmail.com>
Fri, 28 Feb 2025 15:02:10 +0000 (15:02 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 29 May 2025 09:12:58 +0000 (11:12 +0200)
[ Upstream commit 39e912a959c19338855b768eaaee2917d7841f71 ]

Since the driver is broken in the case that src->freq_supported is not
NULL but src->freq_supported_num is 0, add an assertion for it.

Signed-off-by: Jiasheng Jiang <jiashengjiangcool@gmail.com>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
Reviewed-by: Arkadiusz Kubalewski <arkadiusz.kubalewski@intel.com>
Link: https://patch.msgid.link/20250228150210.34404-1-jiashengjiangcool@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/dpll/dpll_core.c

index 1877201d1aa9fef1ec45c524297b70b7ad55563e..20bdc52f63a5031feba8e037253c793f094f0aec 100644 (file)
@@ -443,8 +443,11 @@ static void dpll_pin_prop_free(struct dpll_pin_properties *prop)
 static int dpll_pin_prop_dup(const struct dpll_pin_properties *src,
                             struct dpll_pin_properties *dst)
 {
+       if (WARN_ON(src->freq_supported && !src->freq_supported_num))
+               return -EINVAL;
+
        memcpy(dst, src, sizeof(*dst));
-       if (src->freq_supported && src->freq_supported_num) {
+       if (src->freq_supported) {
                size_t freq_size = src->freq_supported_num *
                                   sizeof(*src->freq_supported);
                dst->freq_supported = kmemdup(src->freq_supported,