From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from smtp06.smtpout.orange.fr ([80.12.242.128] helo=smtp.smtpout.orange.fr) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Y6lzM-0004rO-Ca for barebox@lists.infradead.org; Thu, 01 Jan 2015 20:04:57 +0000 From: Robert Jarzmik Date: Thu, 1 Jan 2015 21:04:21 +0100 Message-Id: <1420142663-6243-1-git-send-email-robert.jarzmik@free.fr> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "barebox" Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: [PATCH] commands: loady: fix bug with netconsole To: barebox@lists.infradead.org Netconsole doesn't have a baudrate. Loady supposes a console has one, and tries to compute the console's baudrate variable value, regardless of its existence. This triggers a NULL pointer dereference on netconsole. If attempting loady on a netconsole is a bit useless, barebox should not panic. Fix this by checking the variable exists before reading its value. Signed-off-by: Robert Jarzmik --- commands/loadxy.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/commands/loadxy.c b/commands/loadxy.c index df14043..1e65cb6 100644 --- a/commands/loadxy.c +++ b/commands/loadxy.c @@ -43,10 +43,10 @@ static int console_change_speed(struct console_device *cdev, int baudrate) { int current_baudrate; + const char *bstr; - current_baudrate = - (int)simple_strtoul(dev_get_param(&cdev->class_dev, - "baudrate"), NULL, 10); + bstr = dev_get_param(&cdev->class_dev, "baudrate"); + current_baudrate = bstr ? (int)simple_strtoul(bstr, NULL, 10) : 0; if (baudrate && baudrate != current_baudrate) { printf("## Switch baudrate from %d to %d bps and press ENTER ...\n", current_baudrate, baudrate); -- 2.1.0 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox