linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [bug report] OPP: Use generic key finding helpers for level key
@ 2022-06-13 13:22 Dan Carpenter
  2022-06-14  2:46 ` Viresh Kumar
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2022-06-13 13:22 UTC (permalink / raw)
  To: viresh.kumar; +Cc: linux-pm

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [bug report] OPP: Use generic key finding helpers for level key
  2022-06-13 13:22 [bug report] OPP: Use generic key finding helpers for level key Dan Carpenter
@ 2022-06-14  2:46 ` Viresh Kumar
  0 siblings, 0 replies; 2+ messages in thread
From: Viresh Kumar @ 2022-06-14  2:46 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: linux-pm

On 13-06-22, 16:22, Dan Carpenter wrote:
> 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?

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.

-- 
viresh

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-06-14  2:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-13 13:22 [bug report] OPP: Use generic key finding helpers for level key Dan Carpenter
2022-06-14  2:46 ` Viresh Kumar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).