OPP: Use generic key finding helpers for level key
Hello Viresh Kumar,
The patch b26e72f76892: "OPP: Use generic key finding helpers for level key" from Jun 2, 2022, leads to the following Smatch static checker warning:
drivers/opp/core.c:688 dev_pm_opp_find_level_ceil() warn: passing casted pointer 'level' to '_find_key_ceil()' 32 vs 64.
drivers/opp/core.c
678 * ERANGE: no match found for search
679 * ENODEV: if device not found in list of registered devices
680 *
681 * The callers are required to call dev_pm_opp_put() for the returned OPP after
682 * use.
683 */ 684 struct dev_pm_opp *dev_pm_opp_find_level_ceil(struct device *dev,
685 unsigned int *level)
^^^^^^^^^^^^^^^^^^^^
686 {
687 return _find_key_ceil(dev, (unsigned long *)level, 0, true,
^^^^^^^^^^^^^^^^^^^^^^
This will corrupt memory.
Fortunately, there are not callers so we are safe... Can we just delete this instead of fixing the corruption?
--> 688 _read_level);
689 }regards,
dan carpenter
Quoted 24 lines · Dan Carpenter
Hello Viresh Kumar,
The patch
b26e72f76892: "OPP: Use generic key finding helpers for level key" from Jun 2, 2022, leads to the following Smatch static checker warning:drivers/opp/core.c:688 dev_pm_opp_find_level_ceil() warn: passing casted pointer 'level' to '_find_key_ceil()' 32 vs 64.
drivers/opp/core.c678 * ERANGE: no match found for search 679 * ENODEV: if device not found in list of registered devices 680 * 681 * The callers are required to call dev_pm_opp_put() for the returned OPP after 682 * use. 683 */684 struct
dev_pm_opp*dev_pm_opp_find_level_ceil(struct device *dev,
685 unsigned int *level)
^^^^^^^^^^^^^^^^^^^^
686 {
687 return _find_key_ceil(dev, (unsigned long *)level, 0, true,
^^^^^^^^^^^^^^^^^^^^^^
This will corrupt memory.
Quoted 2 lines
Fortunately, there are not callers so we are safe... Can we just delete this instead of fixing the corruption?
I expect the callers to be added eventually, so fixed the offending patch itself. Thanks.
The same problem was there in bandwidth specific helpers too, fixed them as well.
Signature · 1 line
viresh