Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp11877pxb; Wed, 30 Mar 2022 21:22:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwSJrZKqP/dr2UqZEkS7VLkNZv6JrK8rSM5y5gZnn1ry3t/M3AKubTqnx5Z26WpS+d9cV0B X-Received: by 2002:a17:90b:3b44:b0:1c7:9ca8:a19e with SMTP id ot4-20020a17090b3b4400b001c79ca8a19emr3831440pjb.245.1648700549410; Wed, 30 Mar 2022 21:22:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648700549; cv=none; d=google.com; s=arc-20160816; b=wsgWd5hD8gqZMAZZYZVUaji5gJPnwjmawDOCuKxXy9cY1bWg/R6YAesr8krWPYNaYf BeCPBOPRlQUU0IcaDkTJh26XA/Mq6ipp3Djp3JRmMyYXpz51UFYvihxpdtJdWBlHX91a yvOlJeWQ9fu4gMDd+/aZ6Y/k+WRTQT1uRi6gkmFZtOH7KNEcjj/pAxT56+YL4/krXxdj IKjmcVVvaoUgX45t7kIUzj2vbnND8cNdGqyuUmyN63NYWPwYw5k5DRW7MB8IoxUe7UIM +Dp6InbsqI0bKJJ3CvdoOZuIi8nd9rimM0KErMrcTX/c2LJrJFP5HdT9u/l9SK3seEB8 kh3g== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Rd3cusIlIuLEAJExg6/4uJHWFJMh1qiW8r4VZKhX5/4=; b=jKImtdkbik9uSaCTQ4PFzRX9fXOaOfQMx5BIJ+eY+sGi+BJdfqLRa+XsBZaLSFCS2I PVu4ByRcxTgD4BIgWRNq/GwU3T455hoS2Gt1JQRDkyuwvt/xl5Rnk38xdIdcGDbgLaXv Ka/jXYvdqcEwHBS+QiSZro4z0MHb5ksrKlkbHOUlLi4VSpAqZmSS1jmBbPJPgd8SU0y3 Cpo9AlQpslBqXz+iz7ts5KM07/Ro17E5MBEOiX/qB5dsGj6cdCCU3GNcpGXELIVhEVLn rycq2tFBMe/jcZHKWp7TPvdZ/r6rL/bYXucwlGXuwNRKu1VPPrFs3kclVqap67OzRenh fPKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TwA0NSrf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id q9-20020a170902e30900b00155c9c5be01si20335627plc.570.2022.03.30.21.22.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Mar 2022 21:22:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TwA0NSrf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2DB54103DAB; Wed, 30 Mar 2022 20:17:58 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344913AbiC3L5h (ORCPT + 99 others); Wed, 30 Mar 2022 07:57:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344487AbiC3LxN (ORCPT ); Wed, 30 Mar 2022 07:53:13 -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 ABC11262410; Wed, 30 Mar 2022 04:48:57 -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 9C61B6137A; Wed, 30 Mar 2022 11:48:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 23718C340EE; Wed, 30 Mar 2022 11:48:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1648640937; bh=/hJvC2gf0i2zGMllIvwBp0yhdrPxL94SQLzsN5wb/G8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TwA0NSrf3Owe2Ri+jPXP6zFCv3Y3Gkyy6T2Fe64pOjBZCmGbWuX4QsvVVI7Lh3Q0R 1A8S9gvSTF2jEBFuTTvpyvXs4qO9E/2konaoUkD0MrVm/Fk5Ab6LbG99jPTFLm6NLs rtPsVbp5p/f8FjJdMr0S1IIn2YV6WBEIKnr/jSY0EEf6u6MJB0MsEtzOiQbWy2OyPZ I+y086xjN2ZlZkRAfodnk63UhuehuKnk3CLIWdMs3/Hbuhlv/XMQZakJuKwMElgKni fmpZ1+siHvY1qiXpxiUtEkmjuMIbX0WLqv5tgB9+z5uDl1RM4lM1sA6HWtSGngqYii hvv/ipOhfBJLw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Evgeny Novikov , Kirill Shilimanov , Helge Deller , Sasha Levin , tomi.valkeinen@ti.com, linux-fbdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.16 15/59] video: fbdev: w100fb: Reset global state Date: Wed, 30 Mar 2022 07:47:47 -0400 Message-Id: <20220330114831.1670235-15-sashal@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220330114831.1670235-1-sashal@kernel.org> References: <20220330114831.1670235-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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: Evgeny Novikov [ Upstream commit 8738ddcac644964ae128ccd3d80d48773c8d528e ] w100fb_probe() did not reset the global state to its initial state. This can result in invocation of iounmap() even when there was not the appropriate successful call of ioremap(). For instance, this may be the case if first probe fails after two successful ioremap() while second probe fails when first ioremap() fails. The similar issue is with w100fb_remove(). The patch fixes both bugs. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Evgeny Novikov Co-developed-by: Kirill Shilimanov Signed-off-by: Kirill Shilimanov Signed-off-by: Helge Deller Signed-off-by: Sasha Levin --- drivers/video/fbdev/w100fb.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/video/fbdev/w100fb.c b/drivers/video/fbdev/w100fb.c index d96ab28f8ce4..4e641a780726 100644 --- a/drivers/video/fbdev/w100fb.c +++ b/drivers/video/fbdev/w100fb.c @@ -770,12 +770,18 @@ static int w100fb_probe(struct platform_device *pdev) fb_dealloc_cmap(&info->cmap); kfree(info->pseudo_palette); } - if (remapped_fbuf != NULL) + if (remapped_fbuf != NULL) { iounmap(remapped_fbuf); - if (remapped_regs != NULL) + remapped_fbuf = NULL; + } + if (remapped_regs != NULL) { iounmap(remapped_regs); - if (remapped_base != NULL) + remapped_regs = NULL; + } + if (remapped_base != NULL) { iounmap(remapped_base); + remapped_base = NULL; + } if (info) framebuffer_release(info); return err; @@ -795,8 +801,11 @@ static int w100fb_remove(struct platform_device *pdev) fb_dealloc_cmap(&info->cmap); iounmap(remapped_base); + remapped_base = NULL; iounmap(remapped_regs); + remapped_regs = NULL; iounmap(remapped_fbuf); + remapped_fbuf = NULL; framebuffer_release(info); -- 2.34.1