Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4442386imw; Tue, 19 Jul 2022 06:44:39 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tnJL/l8B5Yg+Y+P+CUqxxD6Bes/W3901UnMmo0V6dv8ObkDTiatMic5L6yqD2sqA1DRl4X X-Received: by 2002:a17:906:7c0c:b0:6f9:1fc:ebf3 with SMTP id t12-20020a1709067c0c00b006f901fcebf3mr30014649ejo.403.1658238279689; Tue, 19 Jul 2022 06:44:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658238279; cv=none; d=google.com; s=arc-20160816; b=uxMcocTjGvvALU85ixp9v24xn0ZGf9y0oRTAWH1uYT6uEQlDWEe6pVDl3eyU+hyZ5M B8a464MKLQGDM35eRHbD3RDX62Vofl2SK3aQpII3irX1Xeo53xbaMllPK7UGZ6WcXjcJ 9M45nLHyZyS4+Vdu7AN52pHcgTapDwfYnKY9mwPk3DUHW4h5IJRRArBi2gtlqCIavCdc TxOKn2rXk8ZFhYBrMyeyhQaMfDGVnODDgpJlRhf7P4bQbfPfR0FBcj8NsVFtzq2+gals VNgc6CNTwuzeCUlE8B7m7D1GkT5UMiDSjjzpSv4tD408s6Eb0lE/Ri3jJkkzfHlU7jK8 cdpw== 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=mkTP5zVL/H7Ug5Ss9p3oMKkq+FXb96xLndQ//kgsC6I=; b=JmGK2yury1XoETjnf1r5SPjIL4VruPN77FFvQDDQeYY5vwdnESSV5PIZFlYzpzi+ie YgKOxzqZ2ksX/c54DsMwfh+ZMC47FbZiWKW3UAa/5ujd1dibBtU560nOtlT/UyUl+9mp B40D1lPsirrHAWh0+iNxZq3LyMRIXTbMVu311Z5CPV1om0ufddzPCnrH2Jd4UW5mp1w6 sUTc0k7t3lpi7L29Z0DEq3PP4DIzi6+IAAtL9q+uY7HJoR3tJm3KoL+dh6nbGrYEpl2V aCi6R0436B7m7yTPHwoQOkmozfpPIP/+ZzQoj/fsZ022ndclS3uS2PZgTj7VAe5otYrQ ylnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=I+oZi5N2; 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 b13-20020a056402278d00b0043a9e920c24si21655148ede.3.2022.07.19.06.44.14; Tue, 19 Jul 2022 06:44:39 -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=I+oZi5N2; 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 S240049AbiGSM1E (ORCPT + 99 others); Tue, 19 Jul 2022 08:27:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240366AbiGSMYy (ORCPT ); Tue, 19 Jul 2022 08:24:54 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0DA0250719; Tue, 19 Jul 2022 05:09:45 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 6C9CC616DB; Tue, 19 Jul 2022 12:09:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3BCC1C341C6; Tue, 19 Jul 2022 12:09:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658232584; bh=7deDS6NCBIIKmRfnBPGe+kGE6hQ5eD5poALJ+U+mWdI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I+oZi5N2xu9T6X3e6xqvyWc0M4sG705vjNDmZA9P/G5L/ZQvytDEv6gepCWj4aEZH Iju7NrZHxpjR7gPV06ycCDow5USsnfAi3zPlFaoymT/bp1MbkUbZjaAa8ueFPcqVOH iRX+ub7B486+AkGsVABFYgWxqdVwnb6h66dn3vmM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yi Yang , stable Subject: [PATCH 5.10 108/112] serial: 8250: fix return error code in serial8250_request_std_resource() Date: Tue, 19 Jul 2022 13:54:41 +0200 Message-Id: <20220719114637.619381330@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220719114626.156073229@linuxfoundation.org> References: <20220719114626.156073229@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 @@ -2953,8 +2953,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;