Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4367734imw; Tue, 19 Jul 2022 05:27:37 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uUeEVUz3dokOv8LaD4QMlN5P0Fgsl21Lby/gfSmdIEApwOGt3nvzZDsiBNalY1m6fn0k3u X-Received: by 2002:a17:906:ff48:b0:72f:10c:bb3f with SMTP id zo8-20020a170906ff4800b0072f010cbb3fmr19205535ejb.718.1658233657379; Tue, 19 Jul 2022 05:27:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658233657; cv=none; d=google.com; s=arc-20160816; b=rB3YudqOFqohDzMBm5u8TIcbrgDVLyIqG0wIYBuCKQz/Du0mVXU7fU5l6FZSZFQ45Q ERVTzrD08W/JTWxQrJ7Vr8D/bjcxKHCrpFdhE3Ig5CSuF0mlgvyFQ++Yc4/S6ItRcEqn IKU95T1X01ful8MrJ2e1vq27H+rJid8HlTb0Dc6x+v23Z7r28W4u3LLxFNlhnqLNGsRr a1coLr4RAVVUA7efD4EOP60lQn7AdVu4ik4GQSzM6Tq9UOVqcuups9EF6h3HFYpvHHig XUhI+vjYldDwnoonzu4sT1RjrdZEc7PcBaGcMp7zN3qPWKD4Q8B9wgFLUUScVs5Rj2u9 oA2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=FnGjszTn562Bd6CF/5tpb9G9QDkGFMGVAu4BgISzZ10=; b=asdQrdZ7NYdc5PRwbWI4bfvSDHWs7D3UX48aytQalJP7uNq4pNeg42vKLUTjxfaAJh M9Cl2pk1Cyzwt9GysZNyOpEtD/3GoVrkAxByMTGNSKpJtkVKWYmFDvZEh4Lvf4Kg2usl gQXQZnGLZhaoKz2lThko/hEDmd2eWIRJAzA4E81he02GCwLtPiPJXa02MIwAP3qK82ye eVPS3BPcgtCSgdEdFpVC8oJimwJdAB9mikQNJXjrnFZs7dd7Fua+xszSwcNu1SVKTtZP aqWoTht/j6KiwdYg8qtPAnzBXA9WAqo3/0HqncmA+AuFKxEDIh6reYfr4RqjtmqMnDu4 7z8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BDEhM7sM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g8-20020a1709065d0800b0072b4bdab026si16171292ejt.92.2022.07.19.05.27.11; Tue, 19 Jul 2022 05:27:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BDEhM7sM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237546AbiGSL5V (ORCPT + 99 others); Tue, 19 Jul 2022 07:57:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237528AbiGSL4x (ORCPT ); Tue, 19 Jul 2022 07:56:53 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A136A42AC5; Tue, 19 Jul 2022 04:56:31 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 551BAB81B25; Tue, 19 Jul 2022 11:56:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8FD53C341C6; Tue, 19 Jul 2022 11:56:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658231789; bh=VLVde4WyU3r9G4I6zy3LLwY24OSGIE0AYQEeL+lw+FA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BDEhM7sMcN39pWhs7bKJeNJ5QePUsvN5+pPEK9XSsF+Y+9NtXbsHOq6XDOT+xp11w TfGzODgoZQ5R0YOj+qdYNtkrKwwHdXIAVuE63JXZQL0z/p5siSJXgTcbO9R8bWAcsz BFVi/9L/19N3iExLNSrZZ+nH9bVgRJfMNPtHufvc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yi Yang , stable Subject: [PATCH 4.9 26/28] serial: 8250: fix return error code in serial8250_request_std_resource() Date: Tue, 19 Jul 2022 13:54:04 +0200 Message-Id: <20220719114458.550479689@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220719114455.701304968@linuxfoundation.org> References: <20220719114455.701304968@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yi Yang commit 6e690d54cfa802f939cefbd2fa2c91bd0b8bd1b6 upstream. If port->mapbase = NULL in serial8250_request_std_resource() , it need return a error code instead of 0. If uart_set_info() fail to request new regions by serial8250_request_std_resource() but the return value of serial8250_request_std_resource() is 0, The system incorrectly considers that the resource application is successful and does not attempt to restore the old setting. A null pointer reference is triggered when the port resource is later invoked. Signed-off-by: Yi Yang Cc: stable Link: https://lore.kernel.org/r/20220628083515.64138-1-yiyang13@huawei.com Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/8250/8250_port.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/drivers/tty/serial/8250/8250_port.c +++ b/drivers/tty/serial/8250/8250_port.c @@ -2789,8 +2789,10 @@ static int serial8250_request_std_resour case UPIO_MEM32BE: case UPIO_MEM16: case UPIO_MEM: - if (!port->mapbase) + if (!port->mapbase) { + ret = -EINVAL; break; + } if (!request_mem_region(port->mapbase, size, "serial")) { ret = -EBUSY;