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=unavailable 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 5AFC7C43463 for ; Fri, 18 Sep 2020 02:56:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 292272083B for ; Fri, 18 Sep 2020 02:56:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600397783; bh=EWJcn+IBaqU5jMI0HlN8uN+YF8Kf7JtXNO7GJDL6Qr4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=ImEH/IhA+EnHFPnpVx1QGPtfmhnt6I2MOcyGLcz8Ej/2iB4l1O4DTJ3u/g7zRDbhm ZGhCBmNu1BE2BKHiiZ26odzK15vnb+pZEd1f9msURZc1DWEgzbhoHDJeWNZRmnXdIM vn7VE4wGSOGKqGqB0ma8KWwTOKSN19YVV9xpuloo= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730356AbgIRC4W (ORCPT ); Thu, 17 Sep 2020 22:56:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:56484 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727843AbgIRCHH (ORCPT ); Thu, 17 Sep 2020 22:07:07 -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 853B223998; Fri, 18 Sep 2020 02:06:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600394818; bh=EWJcn+IBaqU5jMI0HlN8uN+YF8Kf7JtXNO7GJDL6Qr4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P4b/v8sMfek/iSqzKiqJIdLEIWB/Wk3K4sI23tGMlnS+k5mtGKNpIfA1KUc/zHvmp LFhO49alJ6JLZ2G+de0xVl5BNTbrKkaJjKJ+DCbiRr4GGKzm70AH6maRIMXmTwBDuO cg1A1bTmT//O70nZYX7IJ+ZKFyg0Q2Pq5ZlsyPz4= 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 5.4 284/330] printk: handle blank console arguments passed in. Date: Thu, 17 Sep 2020 22:00:24 -0400 Message-Id: <20200918020110.2063155-284-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918020110.2063155-1-sashal@kernel.org> References: <20200918020110.2063155-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 971197f5d8ee5..5569ef6bc1839 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -2193,6 +2193,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