* [PATCH] thermal: intel: hfi: Improve the type of hfi_features::nr_table_pages
@ 2022-10-18 11:22 Ricardo Neri
2022-10-28 18:13 ` Rafael J. Wysocki
0 siblings, 1 reply; 3+ messages in thread
From: Ricardo Neri @ 2022-10-18 11:22 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Ricardo Neri, Ravi V. Shankar, Ricardo Neri, Daniel Lezcano,
Amit Kucheria, Zhang Rui, Len Brown, Srinivas Pandruvada,
Aubrey Li, Haowen Bai, linux-pm, linux-kernel
A Coverity static code scan raised a potential overflow_before_widen
warning when hfi_features::nr_table_pages is used as an argument to
memcpy in intel_hfi_process_event().
Even though the overflow can never happen (the maximum number of pages of
the HFI table is 0x10 and 0x10 << PAGE_SHIFT = 0x10000), using size_t as
the data type of hfi_features::nr_table_pages makes Coverity happy and
matches the data type of the argument 'size' of memcpy().
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Amit Kucheria <amitk@kernel.org>
Cc: Zhang Rui <rui.zhang@intel.com>
Cc: Len Brown <len.brown@intel.com>
Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: Aubrey Li <aubrey.li@linux.intel.com>
Cc: Haowen Bai <baihaowen@meizu.com>
Cc: linux-pm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
---
drivers/thermal/intel/intel_hfi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/thermal/intel/intel_hfi.c b/drivers/thermal/intel/intel_hfi.c
index a0640f762dc5..239afe02e518 100644
--- a/drivers/thermal/intel/intel_hfi.c
+++ b/drivers/thermal/intel/intel_hfi.c
@@ -137,7 +137,7 @@ struct hfi_instance {
* Parameters and supported features that are common to all HFI instances
*/
struct hfi_features {
- unsigned int nr_table_pages;
+ size_t nr_table_pages;
unsigned int cpu_stride;
unsigned int hdr_size;
};
--
2.25.1
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] thermal: intel: hfi: Improve the type of hfi_features::nr_table_pages
2022-10-18 11:22 [PATCH] thermal: intel: hfi: Improve the type of hfi_features::nr_table_pages Ricardo Neri
@ 2022-10-28 18:13 ` Rafael J. Wysocki
2022-10-29 22:29 ` Ricardo Neri
0 siblings, 1 reply; 3+ messages in thread
From: Rafael J. Wysocki @ 2022-10-28 18:13 UTC (permalink / raw)
To: Ricardo Neri
Cc: Rafael J. Wysocki, Ricardo Neri, Ravi V. Shankar, Daniel Lezcano,
Amit Kucheria, Zhang Rui, Len Brown, Srinivas Pandruvada,
Aubrey Li, Haowen Bai, linux-pm, linux-kernel
On Tue, Oct 18, 2022 at 1:16 PM Ricardo Neri
<ricardo.neri-calderon@linux.intel.com> wrote:
>
> A Coverity static code scan raised a potential overflow_before_widen
> warning when hfi_features::nr_table_pages is used as an argument to
> memcpy in intel_hfi_process_event().
>
> Even though the overflow can never happen (the maximum number of pages of
> the HFI table is 0x10 and 0x10 << PAGE_SHIFT = 0x10000), using size_t as
> the data type of hfi_features::nr_table_pages makes Coverity happy and
> matches the data type of the argument 'size' of memcpy().
>
> Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
> Cc: Amit Kucheria <amitk@kernel.org>
> Cc: Zhang Rui <rui.zhang@intel.com>
> Cc: Len Brown <len.brown@intel.com>
> Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
> Cc: Aubrey Li <aubrey.li@linux.intel.com>
> Cc: Haowen Bai <baihaowen@meizu.com>
> Cc: linux-pm@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
> ---
> drivers/thermal/intel/intel_hfi.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/thermal/intel/intel_hfi.c b/drivers/thermal/intel/intel_hfi.c
> index a0640f762dc5..239afe02e518 100644
> --- a/drivers/thermal/intel/intel_hfi.c
> +++ b/drivers/thermal/intel/intel_hfi.c
> @@ -137,7 +137,7 @@ struct hfi_instance {
> * Parameters and supported features that are common to all HFI instances
> */
> struct hfi_features {
> - unsigned int nr_table_pages;
> + size_t nr_table_pages;
> unsigned int cpu_stride;
> unsigned int hdr_size;
> };
> --
Applied as 6.2 material, thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] thermal: intel: hfi: Improve the type of hfi_features::nr_table_pages
2022-10-28 18:13 ` Rafael J. Wysocki
@ 2022-10-29 22:29 ` Ricardo Neri
0 siblings, 0 replies; 3+ messages in thread
From: Ricardo Neri @ 2022-10-29 22:29 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Rafael J. Wysocki, Ricardo Neri, Ravi V. Shankar, Daniel Lezcano,
Amit Kucheria, Zhang Rui, Len Brown, Srinivas Pandruvada,
Aubrey Li, Haowen Bai, linux-pm, linux-kernel
On Fri, Oct 28, 2022 at 08:13:15PM +0200, Rafael J. Wysocki wrote:
> On Tue, Oct 18, 2022 at 1:16 PM Ricardo Neri
> <ricardo.neri-calderon@linux.intel.com> wrote:
> >
> > A Coverity static code scan raised a potential overflow_before_widen
> > warning when hfi_features::nr_table_pages is used as an argument to
> > memcpy in intel_hfi_process_event().
> >
> > Even though the overflow can never happen (the maximum number of pages of
> > the HFI table is 0x10 and 0x10 << PAGE_SHIFT = 0x10000), using size_t as
> > the data type of hfi_features::nr_table_pages makes Coverity happy and
> > matches the data type of the argument 'size' of memcpy().
> >
> > Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
> > Cc: Amit Kucheria <amitk@kernel.org>
> > Cc: Zhang Rui <rui.zhang@intel.com>
> > Cc: Len Brown <len.brown@intel.com>
> > Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
> > Cc: Aubrey Li <aubrey.li@linux.intel.com>
> > Cc: Haowen Bai <baihaowen@meizu.com>
> > Cc: linux-pm@vger.kernel.org
> > Cc: linux-kernel@vger.kernel.org
> > Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
> > ---
> > drivers/thermal/intel/intel_hfi.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/thermal/intel/intel_hfi.c b/drivers/thermal/intel/intel_hfi.c
> > index a0640f762dc5..239afe02e518 100644
> > --- a/drivers/thermal/intel/intel_hfi.c
> > +++ b/drivers/thermal/intel/intel_hfi.c
> > @@ -137,7 +137,7 @@ struct hfi_instance {
> > * Parameters and supported features that are common to all HFI instances
> > */
> > struct hfi_features {
> > - unsigned int nr_table_pages;
> > + size_t nr_table_pages;
> > unsigned int cpu_stride;
> > unsigned int hdr_size;
> > };
> > --
>
> Applied as 6.2 material, thanks!
Thank you Rafael!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-10-29 22:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-18 11:22 [PATCH] thermal: intel: hfi: Improve the type of hfi_features::nr_table_pages Ricardo Neri
2022-10-28 18:13 ` Rafael J. Wysocki
2022-10-29 22:29 ` Ricardo Neri
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®