lkml.org 
[lkml]   [2015]   [May]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] serial: 8250: Prevent kernel crash with nr_uarts=0
On 05/04/2015 01:45 PM, Jan Kiszka wrote:
> On 2015-05-04 19:02, Peter Hurley wrote:
>> Hi Jan,
>>
>> On 05/04/2015 12:01 PM, Jan Kiszka wrote:
>>> When nr_uarts was set to 0 (via config or 8250_core.nr_uarts), we crash
>>> early on x86 because serial8250_isa_init_ports dereferences base_ops
>>> which remains NULL. In fact, there is nothing to do for that function if
>>> there are no uarts.
>>
>> Thanks for finding this.
>>
>> So nr_uarts == 0 effectively disables the 8250 driver. Is there any
>> reason not to simply abort the driver init instead?
>
> I'm not very deep into this code, just stumbled over this while trying
> some, well, unusual configurations.

Ok; I wasn't sure if this was related to some weird setup that needed
the 8250 driver loaded but in-op.

> If you prefer to handle this differently, I can recode it, of course.

Yes, please. We should bail out of any initialization if nr_uarts == 0.

That would be:
1. univ8250_console_init()
The return value is ignored but the console should not be registered.

2. early_serial_setup()

if (nr_uarts == 0)
return -ENODEV;

3. serial8250_init()

if (nr_uarts == 0)
return -ENODEV;


Regards,
Peter Hurley


\
 
 \ /
  Last update: 2015-05-04 21:21    [W:0.099 / U:0.068 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site