From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E3F4DC43464 for ; Fri, 18 Sep 2020 02:30:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B122E21973 for ; Fri, 18 Sep 2020 02:30:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600396257; bh=w1lb9REZr+ctoHFQ0Y5pTJcvB4ovwCQDN7W8p0KoojI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=MVgmdT+TMXbDZiQe/NMgZ4NuJxEwwWamIw25NiJ5EG7Ze1F3D5/40WX3Plt24/phH zFgmMasR/Qh8/eBSrJJBig2QsJkT+OGWjKAES8Y+n1uiUasXPU5W5+jol8VoKbmOgj Xnu3MmWfoRzjxgqNSuMPyyuWfE9EP8lwtgoTNDQ4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729814AbgIRCaw (ORCPT ); Thu, 17 Sep 2020 22:30:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:42592 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729084AbgIRCO3 (ORCPT ); Thu, 17 Sep 2020 22:14:29 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 270D72388D; Fri, 18 Sep 2020 02:14:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600395268; bh=w1lb9REZr+ctoHFQ0Y5pTJcvB4ovwCQDN7W8p0KoojI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Yg1711yIAsZaKwEuEa9H3nwFpmFhEh8zPtXcsuXkkiHUmVQQylWFakLGgbad/8L2p QBsjE3AZJRj2tmLW9Sy9c453xzgkRHEekIsC6sbaYdBq6+6pNzaGoYg2Mzav83pXX8 OIIh90ULTmTR1dxTujocZoEk0/nknQE34DOw88JA= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Shreyas Joshi , Sergey Senozhatsky , Petr Mladek , Sasha Levin Subject: [PATCH AUTOSEL 4.14 108/127] printk: handle blank console arguments passed in. Date: Thu, 17 Sep 2020 22:12:01 -0400 Message-Id: <20200918021220.2066485-108-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918021220.2066485-1-sashal@kernel.org> References: <20200918021220.2066485-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Shreyas Joshi [ Upstream commit 48021f98130880dd74286459a1ef48b5e9bc374f ] If uboot passes a blank string to console_setup then it results in a trashed memory. Ultimately, the kernel crashes during freeing up the memory. This fix checks if there is a blank parameter being passed to console_setup from uboot. In case it detects that the console parameter is blank then it doesn't setup the serial device and it gracefully exits. Link: https://lore.kernel.org/r/20200522065306.83-1-shreyas.joshi@biamp.com Signed-off-by: Shreyas Joshi Acked-by: Sergey Senozhatsky [pmladek@suse.com: Better format the commit message and code, remove unnecessary brackets.] Signed-off-by: Petr Mladek Signed-off-by: Sasha Levin --- kernel/printk/printk.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 4e50beb162c00..f96b22db5fe70 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -2092,6 +2092,9 @@ static int __init console_setup(char *str) char *s, *options, *brl_options = NULL; int idx; + if (str[0] == 0) + return 1; + if (_braille_console_setup(&str, &brl_options)) return 1; -- 2.25.1