Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp704656pxb; Tue, 5 Apr 2022 19:33:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxI4wC4tnSQ9dabKYmvg865VDCkGT6VSPWo7yb2ujVs1IPSxyIMNc0pW86zMWTstDkBq9rl X-Received: by 2002:a50:d48d:0:b0:41a:c9cb:8b90 with SMTP id s13-20020a50d48d000000b0041ac9cb8b90mr6482295edi.299.1649212387022; Tue, 05 Apr 2022 19:33:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649212387; cv=none; d=google.com; s=arc-20160816; b=sVmqZNoooEtMHWovr98rs722iTy358gMIks8HxCfWlxDQNR055G3bwdLNwO/G/uhKd 9eoy9azrt5RLIXQMjAQyqXQEcxQXMCXB025mRhS3/lKOqZQ0PSW3jXyfWZA0gNBDyR4f unCgfTqH+gF6SNvUKts/r4xQUXswlUly2Atlvx3UHy0hUfqk+FTphqgqpcJFkS64m0hm r3n4Ii/lkZUa209l/+mE67Ftf14dPnLvO6QJiM7BMOVh1ucdb/RrkEww+9Ohao6K3tPe zoM2f4vMv3Qg/OuwhhJWnqIx5zhIg50YJm6JOdIcO0yQ3trhVOhgeJ2WV6DLqTz7WRrx Tegg== 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=Rd3cusIlIuLEAJExg6/4uJHWFJMh1qiW8r4VZKhX5/4=; b=KzsJPI4oMh+WDEk4Fpko5f8nKMgMYxffdCLCj20E49Kmv7rqIJz4NJD8n6P73R3Y8Y JrmrnLStXHARbdrPE4dwQPzX5GcJwlo64+leEoTHpJutOmtZIMbfFidSzGjcStQ1G9Nr o0cFqFIeQR9wqAtmIWGCWHWE0Y+vqYqToxSWCWL2SXxYac252d8tWxa4/wdxChmfUzIP de5w4xisC9gzBdHvehEvrR2vJ5UUyTbele8ISzW5irgVkchwGg0TQHSmSQy84mCy1MBS nrALLu2YjB08O+71B+BeTwpsnQ8RyXhbxIiHoGZwcaqqU34Rv3D2qw6zk5T9v1YHU/LS g6yQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=yYiV22V1; 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 w14-20020a1709062f8e00b006e80297a928si4549507eji.469.2022.04.05.19.32.42; Tue, 05 Apr 2022 19:33:07 -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=yYiV22V1; 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 S240464AbiDEN5m (ORCPT + 99 others); Tue, 5 Apr 2022 09:57:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344777AbiDEJVM (ORCPT ); Tue, 5 Apr 2022 05:21:12 -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 295F2252A9; Tue, 5 Apr 2022 02:08:43 -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 6AEFB61579; Tue, 5 Apr 2022 09:08:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 74C21C385A1; Tue, 5 Apr 2022 09:08:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649149721; bh=/hJvC2gf0i2zGMllIvwBp0yhdrPxL94SQLzsN5wb/G8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yYiV22V1i6Rews0XKd6TGlJiokS/30mOTWf5/SMgu0U+Lzu3+fByCE9nrcoYPsw1c EaXlNm32EcXjJeTrA4d7BkMkURoVLkrGdJ+tjA9Nzde6H8Engkw7thqer8qJmYU5fR xTDihaqNLQ0Gpb86r4UEeKyTFH/bCVC4fL2vN19g= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Evgeny Novikov , Kirill Shilimanov , Helge Deller , Sasha Levin Subject: [PATCH 5.16 0817/1017] video: fbdev: w100fb: Reset global state Date: Tue, 5 Apr 2022 09:28:50 +0200 Message-Id: <20220405070418.500844763@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070354.155796697@linuxfoundation.org> References: <20220405070354.155796697@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.1 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,T_SCC_BODY_TEXT_LINE 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: 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