Received: by 2002:ab2:784b:0:b0:1fd:adc2:8405 with SMTP id m11csp241758lqp; Mon, 10 Jun 2024 02:36:10 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWLlk7wuUQmnOei0lfvS7R6GaeDTsyTXzy8+Y8/EV2P3Y2kctszAFmnjpjm/et09kZ3mHxgvro3l6Qeam+9il5BU2/Vc2lySomI0zEATA== X-Google-Smtp-Source: AGHT+IEN9WioSBY/x/axbggM2Ao2VHTrPGdl2LfMen52Qp6lrm6bkNvWfkkGiBqBCxcBvmetdrb4 X-Received: by 2002:a17:902:e881:b0:1f7:1495:6ebd with SMTP id d9443c01a7336-1f7149573c7mr29100945ad.18.1718012169763; Mon, 10 Jun 2024 02:36:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718012169; cv=pass; d=google.com; s=arc-20160816; b=pECqfxWU0g0QkxDosSOz7GiXASg19JaQCZ5/bH6+IAmo5VIGVShg63dkI4cNOpW2XG 7t2M+5AFhK9NnU1nLugzejTbI/ZqXSXo81E+cjKbX8E6GFhJqG5cuVHfZn/xzGONSGAP S6C9f/kGiioXOXptyvx3NLUGHNDkHlry6CtuP7MAbn8yObUsFpeO7A1C3tyBGykB5wdQ slGifd7nEgGRy0KvmNlkB86tpClROb3N01rhyqiZP9AhKQx8yTw7e3aOS5lPn2rtuB+E Y0iH+hfnHAdS3wBzeemTDbZd8V/JrRYPE3QN8NU0dEsYrWFr+20Tq5TUpgEZSP3OW9Pc /pKA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=9WQJKGGQ63IpYpwAqks0j3zwgngy8EFW/hBQkkDLpOw=; fh=j6zL2vlrWxAsmemy9vGLuwWfBJkpeHBblIvHHOK6tWM=; b=doABSySSxbGVlR9hLur/FzXMowCXkcJIgU1t8TjThi057T5wbMXP1nKtQtFgv2J5KF 8Z9SahxUgEUp/iHvdvLmPzsFUujm3nB8buwmyN7/a1kYdq/CHPcnBqT3onpPeyBsoT1u IfL2jSrUp2Pw01Pd7WmA4WaaSO6YA4Ku3kL8I3y1O21I+LnUzp8RvS1GnQLmbiu9glbp q9oenEGkd5mZeH34dCPxrY79nJUzAxn98WSlcgOEetUVgpxY5XjpOD56/G0lOgjoAkee a61LTQEmEC1bOHwZlMZLAQjz9UJyFI3BC4Diq40Huqyprg+KfgEoElXYyhm+BtbKLtUP BZyQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hRiGn2ji; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-207952-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-207952-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d9443c01a7336-1f6bd81da53si65595905ad.556.2024.06.10.02.36.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 02:36:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-207952-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hRiGn2ji; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-207952-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-207952-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 91BDA2835A6 for ; Mon, 10 Jun 2024 09:35:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3D6D681745; Mon, 10 Jun 2024 09:32:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="hRiGn2ji" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C5E1F8005B for ; Mon, 10 Jun 2024 09:32:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718011940; cv=none; b=IcXnUJpA3/Ce7+HLPQnkFR9BfDxhC4Uy34wdg1HXHhww50upjwCCBx0KPIf6GAtza06vH4ojyZjFWzS7ye9SYCv5gOy75b7aOtBqb2rQoeqG89x1FHRCl3bwV9mbftkHGkblV211teCdzub7ttaqtDQdzNdEPokCBxfgM1pq744= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718011940; c=relaxed/simple; bh=iGO9d2tDV8jgMXAb9ljo4BmxYhAXls7ncq8pchC9GTM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=k1efuVhVqg7y3OBowjQVPfpkJPiGRG8bnQLp4BiL/trlaD1lBOwew2s7sxvFYTfQlNxU1TYnUgL6rpfAPfZq/rw6wqhjZ5r+NIlKwlIk09fcezFY6FbNCyThZItSdrfNwhNa+jO1hbzNlUm0ei46fnpFYVs/Fi8Oy7N2qRN4nK4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=hRiGn2ji; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718011938; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9WQJKGGQ63IpYpwAqks0j3zwgngy8EFW/hBQkkDLpOw=; b=hRiGn2jiTKeoe6jpy3OAr3JM0PnnpWtIG7YuFWuY3A0y8I9Q4heDm+4RaXHDblQePfbacb OaMurPuqTK6UFRYT0pWY+M1ZwgeKp3/uUg2zZND5nhtYh7EY5nleqmX2pLXfjGd8Jb2o1C PekcFdP26u7hx5L1OJofLMfkiMvutVA= Received: from mail-lj1-f198.google.com (mail-lj1-f198.google.com [209.85.208.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-427-WmZVQbNOPZGY2KqBT5Fseg-1; Mon, 10 Jun 2024 05:32:14 -0400 X-MC-Unique: WmZVQbNOPZGY2KqBT5Fseg-1 Received: by mail-lj1-f198.google.com with SMTP id 38308e7fff4ca-2eae267d112so3093191fa.1 for ; Mon, 10 Jun 2024 02:32:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718011933; x=1718616733; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9WQJKGGQ63IpYpwAqks0j3zwgngy8EFW/hBQkkDLpOw=; b=WwsIPWcLN4KNYF2ALETS/H3q/l66ooD3/Muo9zbESlW9VPxEh95cH4WE7EaSg7jOXC lPA0oOh2DfS/M1pKjJLuGdF5qyAsAlG/Txgr1D2A4tH26wYJmRZ5CMEhn1UawACFHmaV l694Ar11iHr5W1O8qbzBo9uKAg9o2hVzY/cI10dg81q5hMy/M6xjv7vZyp3zQvaoc7A8 DlLSXLag9BtAJf6d/HNtBIXeiYKqFc0Cv6gn6r0+MyKQPZYmDY4js9MZ95Xr1glMxs6d yr5wGxbXvWLXP6r/QCWcGGKuXeyAuharDiF6udXJTg7BhehQrN2AzfLZYsdcHHCzTM5x 57NA== X-Forwarded-Encrypted: i=1; AJvYcCVSqFuS/k9622OudMwdipXkk9yMT1kJ6Y4CTbpCG9XI9lE0rvUlt58WnIU4PX/IiNqZ8OTE73GBmd3T4Yj99Dq3X2vrHDK1TtP7eJVb X-Gm-Message-State: AOJu0YxPIdjrrY6hA2nXcMSLF4s3hJe1bQKCxZgWuR346px9rUwCFd6X n3G1EmXp+MpCcay+CNRfusTM7if9ofD1KS6QJywTeoh+S4H2ZORh0MZ2sFbwkQMeqwEWBDuWpJU LB5ZC4LDcixiH6rRoF3sw20HQl1XWtQdDyOje5mQ8f/+ptdksjlZioelfPMjdVQ== X-Received: by 2002:a19:2d0d:0:b0:52c:8857:7631 with SMTP id 2adb3069b0e04-52c88577793mr2123921e87.1.1718011933078; Mon, 10 Jun 2024 02:32:13 -0700 (PDT) X-Received: by 2002:a19:2d0d:0:b0:52c:8857:7631 with SMTP id 2adb3069b0e04-52c88577793mr2123916e87.1.1718011932865; Mon, 10 Jun 2024 02:32:12 -0700 (PDT) Received: from pstanner-thinkpadt14sgen1.muc.redhat.com (nat-pool-muc-t.redhat.com. [149.14.88.26]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-35f0ce4b62fsm7257545f8f.80.2024.06.10.02.32.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 02:32:12 -0700 (PDT) From: Philipp Stanner To: Hans de Goede , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Bjorn Helgaas , Sam Ravnborg , dakr@redhat.com Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Philipp Stanner Subject: [PATCH v8 13/13] drm/vboxvideo: fix mapping leaks Date: Mon, 10 Jun 2024 11:31:35 +0200 Message-ID: <20240610093149.20640-14-pstanner@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240610093149.20640-1-pstanner@redhat.com> References: <20240610093149.20640-1-pstanner@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit When the PCI devres API was introduced to this driver, it was wrongly assumed that initializing the device with pcim_enable_device() instead of pci_enable_device() will make all PCI functions managed. This is wrong and was caused by the quite confusing PCI devres API in which some, but not all, functions become managed that way. The function pci_iomap_range() is never managed. Replace pci_iomap_range() with the actually managed function pcim_iomap_range(). Fixes: 8558de401b5f ("drm/vboxvideo: use managed pci functions") Signed-off-by: Philipp Stanner Reviewed-by: Hans de Goede --- drivers/gpu/drm/vboxvideo/vbox_main.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/vboxvideo/vbox_main.c b/drivers/gpu/drm/vboxvideo/vbox_main.c index 42c2d8a99509..d4ade9325401 100644 --- a/drivers/gpu/drm/vboxvideo/vbox_main.c +++ b/drivers/gpu/drm/vboxvideo/vbox_main.c @@ -42,12 +42,11 @@ static int vbox_accel_init(struct vbox_private *vbox) /* Take a command buffer for each screen from the end of usable VRAM. */ vbox->available_vram_size -= vbox->num_crtcs * VBVA_MIN_BUFFER_SIZE; - vbox->vbva_buffers = pci_iomap_range(pdev, 0, - vbox->available_vram_size, - vbox->num_crtcs * - VBVA_MIN_BUFFER_SIZE); - if (!vbox->vbva_buffers) - return -ENOMEM; + vbox->vbva_buffers = pcim_iomap_range( + pdev, 0, vbox->available_vram_size, + vbox->num_crtcs * VBVA_MIN_BUFFER_SIZE); + if (IS_ERR(vbox->vbva_buffers)) + return PTR_ERR(vbox->vbva_buffers); for (i = 0; i < vbox->num_crtcs; ++i) { vbva_setup_buffer_context(&vbox->vbva_info[i], @@ -116,11 +115,10 @@ int vbox_hw_init(struct vbox_private *vbox) DRM_INFO("VRAM %08x\n", vbox->full_vram_size); /* Map guest-heap at end of vram */ - vbox->guest_heap = - pci_iomap_range(pdev, 0, GUEST_HEAP_OFFSET(vbox), - GUEST_HEAP_SIZE); - if (!vbox->guest_heap) - return -ENOMEM; + vbox->guest_heap = pcim_iomap_range(pdev, 0, + GUEST_HEAP_OFFSET(vbox), GUEST_HEAP_SIZE); + if (IS_ERR(vbox->guest_heap)) + return PTR_ERR(vbox->guest_heap); /* Create guest-heap mem-pool use 2^4 = 16 byte chunks */ vbox->guest_pool = devm_gen_pool_create(vbox->ddev.dev, 4, -1, -- 2.45.0