Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752065AbbEDSxC (ORCPT ); Mon, 4 May 2015 14:53:02 -0400 Received: from mail-qg0-f51.google.com ([209.85.192.51]:34676 "EHLO mail-qg0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751007AbbEDSww (ORCPT ); Mon, 4 May 2015 14:52:52 -0400 Message-ID: <5547C001.8040400@hurleysoftware.com> Date: Mon, 04 May 2015 14:52:49 -0400 From: Peter Hurley User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Jan Kiszka CC: Greg Kroah-Hartman , Linux Kernel Mailing List , linux-serial@vger.kernel.org Subject: Re: [PATCH] serial: 8250: Prevent kernel crash with nr_uarts=0 References: <554797D4.5080704@siemens.com> <5547A614.9020109@hurleysoftware.com> <5547B04C.8080706@siemens.com> In-Reply-To: <5547B04C.8080706@siemens.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1428 Lines: 47 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/