* linux-6.19-rc8/kernel/liveupdate/kexec_handover.c:1089: Possible 32/64 bit mixup ?
@ 2026-02-05 9:21 David Binderman
2026-02-10 13:41 ` Pratyush Yadav
0 siblings, 1 reply; 2+ messages in thread
From: David Binderman @ 2026-02-05 9:21 UTC (permalink / raw)
To: graf, rppt, pasha.tatashin, pratyush, kexec, linux-mm, LKML
Hello there,
Source code analyser cppcheck says:
linux-6.19-rc8/kernel/liveupdate/kexec_handover.c:1089:15: style: int result is assigned to long variable. If the variable is long to avoid loss of information, then you have loss of information. [truncLongCastAssignment]
Source code is
contig_pages = (1 << order);
I admit the error message is hard to understand, but AFAIK
if local variable order remains under 30 or so, then there is no problem.
However, if it goes above 32, then there will be loss of data.
Expression 1 << order is type int.
Suggest add some code or comment to document the expected range
of local variable order. If it ever goes above 32, suggest new code
contig_pages = 1UL << order;
Regards
David Binderman
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: linux-6.19-rc8/kernel/liveupdate/kexec_handover.c:1089: Possible 32/64 bit mixup ?
2026-02-05 9:21 linux-6.19-rc8/kernel/liveupdate/kexec_handover.c:1089: Possible 32/64 bit mixup ? David Binderman
@ 2026-02-10 13:41 ` Pratyush Yadav
0 siblings, 0 replies; 2+ messages in thread
From: Pratyush Yadav @ 2026-02-10 13:41 UTC (permalink / raw)
To: David Binderman
Cc: graf, rppt, pasha.tatashin, pratyush, kexec, linux-mm, LKML
Hi David,
On Thu, Feb 05 2026, David Binderman wrote:
> Hello there,
>
> Source code analyser cppcheck says:
>
> linux-6.19-rc8/kernel/liveupdate/kexec_handover.c:1089:15: style: int result is
> assigned to long variable. If the variable is long to avoid loss of information,
> then you have loss of information. [truncLongCastAssignment]
>
> Source code is
>
> contig_pages = (1 << order);
>
> I admit the error message is hard to understand, but AFAIK
> if local variable order remains under 30 or so, then there is no problem.
>
> However, if it goes above 32, then there will be loss of data.
> Expression 1 << order is type int.
>
> Suggest add some code or comment to document the expected range
> of local variable order. If it ever goes above 32, suggest new code
>
> contig_pages = 1UL << order;
If order is 32, with 4k pages, that means 16 TiB. It is unlikely that we
will see vmalloc area backed by pages this large any time soon. So I am
not worried about any practical problems.
But I think this is still a good idea to do for code hygiene. So a patch
would be much appreciated.
--
Regards,
Pratyush Yadav
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-02-10 13:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-02-05 9:21 linux-6.19-rc8/kernel/liveupdate/kexec_handover.c:1089: Possible 32/64 bit mixup ? David Binderman
2026-02-10 13:41 ` Pratyush Yadav
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox