lkml.org 
[lkml]   [2015]   [Feb]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/1] kernel/fork.c: avoid division by zero
On 17.02.2015 08:56, Vladimir Davydov wrote:
> On Mon, Feb 16, 2015 at 07:00:44PM +0100, Heinrich Schuchardt wrote:
>> diff --git a/kernel/fork.c b/kernel/fork.c
>> index cf65139..71e2583 100644
>> --- a/kernel/fork.c
>> +++ b/kernel/fork.c
>> @@ -273,7 +273,8 @@ void __init fork_init(unsigned long mempages)
>> * value: the thread structures can take up at most half
>> * of memory.
>> */
>> - max_threads = mempages / (8 * THREAD_SIZE / PAGE_SIZE);
>> + max_threads = (u64) PAGE_SIZE * (u64) mempages
>> + / (u64) THREAD_SIZE / 8UL;
>
> This won't compile for a 32 bit arch, will it? Should you use div_u64?
>
> Thanks,
> Vladimir
>
Hello Vladimir,

I compiled the kernel successfully with the patch on a 32bit arm system
and Kernel 3.19.0.

Obviously that was good luck.
http://gcc.gnu.org/onlinedocs/gccint/Integer-library-routines.html
describes that library function __udivti3 might be used on other
platforms. And using library functions is not allowable in the kernel.

Thank you for reviewing. I will update the patch.

Best regards

Heinrich


\
 
 \ /
  Last update: 2015-02-17 10:21    [W:0.040 / U:1.776 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site