Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp5458443pxu; Tue, 22 Dec 2020 18:41:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJwTX07fTM0IunQsdDkAAbQ208wLKQ+JiojOqdQa7hdlIla1R+SmCK/j6EkmznGRk+QJgDA2 X-Received: by 2002:a05:6402:1c8a:: with SMTP id cy10mr22930613edb.151.1608691268611; Tue, 22 Dec 2020 18:41:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608691268; cv=none; d=google.com; s=arc-20160816; b=sQicIQggriYn9pX7fE4dCER8gLOUFHM2szL1fx08edK9dcHhNpf4+nGNqVy5uTaX/L I8Oddnv5ZoPj69/Aw5Rc7UGGPpOy8ZjdO+BC0oskIkxoV99nk8Zw2zl4X6lRjTUu1se/ 0CYWOk+51JmpqBL/rRcGM0bYIB6jSKkGKx+8oG/tckAT7Kq4z+8fCHoutQUHl4IjYI0x +blg6NYAvF7u5d6Qbo0zjU5UvetyJswEMU1A7lh5dbK6h5thZOPNTkyxkqJIcAFdlRT8 QM2HdGAJrjcqtKnGoZuh88dDJfL2cHKuQ20egi8p55bORaL6xyUQPgEfAey89TggYYUh a6sQ== 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=AHnZXiH9QXMlI3i7vuY+1ZApBtAz4VtxDk+Ru4EBcro=; b=cspwsM6gcnu674SRShYRk/CoB7z9v6MvCz9g0PrUmzk3C2Q1fw2x6dK6Eqids3OCqk tPonG/A0VHI1BrWwEK2VNqfqNjx8tkIdYQTXbBKyja0A+pHxk26HDezPOPdUVJamdu4h Dw2CP9MJGin7OAxFJukMqey/lIkUFYWNABkDDGyr7Oohhr9iJNePKxXBq8geXFhSOLwU CX9Uh5Ztz13bguemTyv+j8JGyWLiEMJO+pEneMwoWXV181gyFyMk39gd6UhOOrwZkUPu VBivxXLuzAyZAt/v9MWoiAdQ6XrFKI7mdV9q/S7wI+iB/6P/UghzdNQ0TPiN17ruRa8x gzvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=a1kdaWxO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n22si12889491edb.427.2020.12.22.18.40.46; Tue, 22 Dec 2020 18:41:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=a1kdaWxO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730440AbgLWCkX (ORCPT + 99 others); Tue, 22 Dec 2020 21:40:23 -0500 Received: from mail.kernel.org ([198.145.29.99]:51348 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730022AbgLWCXi (ORCPT ); Tue, 22 Dec 2020 21:23:38 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 011BE22482; Wed, 23 Dec 2020 02:23:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1608690201; bh=5drJtqNzWD0rLt1kAjtVy6gjml1j8+udDTDEYpdbkJk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a1kdaWxO29qVw9qWuQPhz1JUK0GKAmhM3i3glD/eiU4pTcU8ST5/s2T/dRQN1gNZa rHJd+Wd4UmyFLvAE04g9248zx7qj/VSqQd2mi131631dXtWaYRKJBLgEdEKjYAi21N OFMbrzox4/QDeZSyOZhKEru6bknWbxgZ1DDwTnt1/YrHArLC05RdHWGglzh9KDTUqc t5y8bOKT1+DOu+5YZ4jVCk65vhTTO55TXllw9vuogXtqPvbdiBHXdC/IDPYw8QJ1oE sL660GLX29SA/C16jtjTjvZKcyYLq/+aij68S4+hx+wAlgRF3b/blykYFbpf6dEdLD 3F6tqki19pSDQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Evgeny Novikov , Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin , linux-media@vger.kernel.org Subject: [PATCH AUTOSEL 4.14 23/66] media: isif: reset global state Date: Tue, 22 Dec 2020 21:22:09 -0500 Message-Id: <20201223022253.2793452-23-sashal@kernel.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201223022253.2793452-1-sashal@kernel.org> References: <20201223022253.2793452-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Evgeny Novikov [ Upstream commit 6651dba2bd838f34cf5a1e84229aaa579b1a94fe ] isif_probe() invokes iounmap() on error handling paths, but it does not reset the global state. So, later it can invoke iounmap() even when ioremap() fails. This is the case also for isif_remove(). The patch resets the global state after invoking iounmap() to avoid this. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Evgeny Novikov Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/platform/davinci/isif.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/davinci/isif.c b/drivers/media/platform/davinci/isif.c index 12065ad1ac457..e7372319de80d 100644 --- a/drivers/media/platform/davinci/isif.c +++ b/drivers/media/platform/davinci/isif.c @@ -1086,10 +1086,14 @@ static int isif_probe(struct platform_device *pdev) release_mem_region(res->start, resource_size(res)); i--; fail_nobase_res: - if (isif_cfg.base_addr) + if (isif_cfg.base_addr) { iounmap(isif_cfg.base_addr); - if (isif_cfg.linear_tbl0_addr) + isif_cfg.base_addr = NULL; + } + if (isif_cfg.linear_tbl0_addr) { iounmap(isif_cfg.linear_tbl0_addr); + isif_cfg.linear_tbl0_addr = NULL; + } while (i >= 0) { res = platform_get_resource(pdev, IORESOURCE_MEM, i); @@ -1107,8 +1111,11 @@ static int isif_remove(struct platform_device *pdev) int i = 0; iounmap(isif_cfg.base_addr); + isif_cfg.base_addr = NULL; iounmap(isif_cfg.linear_tbl0_addr); + isif_cfg.linear_tbl0_addr = NULL; iounmap(isif_cfg.linear_tbl1_addr); + isif_cfg.linear_tbl1_addr = NULL; while (i < 3) { res = platform_get_resource(pdev, IORESOURCE_MEM, i); if (res) -- 2.27.0