Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp953460pxb; Wed, 6 Apr 2022 05:12:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw3RDqB6Y0cAQuMi3oAKU9ICUJNd2MfMfoFnSircbKE+PqMxLPjTQ1WXazCIFKkFpMV83Sn X-Received: by 2002:a17:90a:d0c5:b0:1c9:ec78:18e5 with SMTP id y5-20020a17090ad0c500b001c9ec7818e5mr9622136pjw.53.1649247157621; Wed, 06 Apr 2022 05:12:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649247157; cv=none; d=google.com; s=arc-20160816; b=svtY0nYVLE11z8zdMNkad+yRZr+sC1Rpxb+U9cvk9O69YbvrXR0gPo1pxC1+CmCB35 EzVbx8ZGjQd83fCTJfZIL203bbD2NAc/ozZk5qOiHeWaEoN2kFtpezUxg1tsVabQbOZC hLPz5zFm9OB3RngfVVFAERK+Fg6chrZQMyS9sc/BvP2fsZ6FiIVi6grExo+xTsxr4f7x AsRb65YYMdPEVsUqRgzeeSotOPWvibbHZ7yGGkvxMXUmP3LuprGygp7IciFxX3DEq9l8 CKHIKUuY6bWXiGb5VnTj0DRz5kfE3OMEbJQicQm7rbHv+eX4/eQhEbxYrnt4Lw6hBdP0 i8cw== 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=z88axX9G3IcB1u2PXotea8q00EzlRZ6rs8TkCDRSyGkD7/vXtsRPylCLPuRnsJc5OV PTTGRDCrECqoIDUtsy93PflRDOz+Dl0ZLbhZ4mTpbNaM0iQbNt8mGpaOR+3Mjqbon7CJ bOa027EAzXdffeQEB98pXEoJY0W2/3xSd4Ti161tme5pcBYwW6xGGXFQHWmtZXmv1yRz 0KruiC0gyYYpmiB86xNEfki32bWnkZ+53Lza3h8gV6mhU8vQ6/qsGUGbv7wwbYRA1EOF /q4DghTwkQRfEaX8U01mH4qZHGbB5sLJjuWEz/JJucUL2WOhnamXntp3mxI0PdKCC2tb 7r7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Tq+LJKJZ; 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=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id q5-20020a17090311c500b001561bf8defdsi15050225plh.592.2022.04.06.05.12.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 05:12:37 -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=@linuxfoundation.org header.s=korg header.b=Tq+LJKJZ; 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=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7936F6AABE5; Wed, 6 Apr 2022 03:50:29 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1842370AbiDFBbR (ORCPT + 99 others); Tue, 5 Apr 2022 21:31:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351851AbiDEKDZ (ORCPT ); Tue, 5 Apr 2022 06:03:25 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4808975C18; Tue, 5 Apr 2022 02:52:17 -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 sin.source.kernel.org (Postfix) with ESMTPS id 3525BCE1C9E; Tue, 5 Apr 2022 09:52:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4B4D7C385A1; Tue, 5 Apr 2022 09:52:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649152334; bh=/hJvC2gf0i2zGMllIvwBp0yhdrPxL94SQLzsN5wb/G8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Tq+LJKJZ9+Pxw9HHy3F3oZTxdMHRK2OTecyuB9f2Csxh4YL+83vVnLyva+iQCwtmI cb0l84qdOVPFBNuKvqEW8iTq/0cVxsOahuOAlMJ2kZjQ/oEGcVl2cDMiiXcnJ29/mW YTajjNRuNRkQ2TtIhbpcF1zlKuQM6XqzYtQvrBUQ= 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.15 738/913] video: fbdev: w100fb: Reset global state Date: Tue, 5 Apr 2022 09:30:00 +0200 Message-Id: <20220405070401.956283853@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070339.801210740@linuxfoundation.org> References: <20220405070339.801210740@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=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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