From patchwork Fri Mar 13 22:22:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikel Rychliski X-Patchwork-Id: 1254700 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=mikelr.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 48fKw14BRDz9sPJ for ; Sat, 14 Mar 2020 09:23:13 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726838AbgCMWXJ (ORCPT ); Fri, 13 Mar 2020 18:23:09 -0400 Received: from yyz.mikelr.com ([170.75.163.43]:57262 "EHLO yyz.mikelr.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726543AbgCMWXJ (ORCPT ); Fri, 13 Mar 2020 18:23:09 -0400 Received: from glidewell.ykf.mikelr.com (198-84-194-208.cpe.teksavvy.com [198.84.194.208]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by yyz.mikelr.com (Postfix) with ESMTPSA id 47A983D5C7; Fri, 13 Mar 2020 18:23:08 -0400 (EDT) From: Mikel Rychliski To: amd-gfx@lists.freedesktop.org, linux-pci@vger.kernel.org, nouveau@lists.freedesktop.org Cc: Alex Deucher , =?utf-8?q?Christian_K=C3=B6n?= =?utf-8?q?ig?= , "David (ChunMing) Zhou" , Bjorn Helgaas , Matthew Garrett , Ben Skeggs , Mikel Rychliski Subject: [PATCH RESEND v2 1/2] drm/radeon: Stop directly referencing iomem Date: Fri, 13 Mar 2020 18:22:57 -0400 Message-Id: <20200313222258.15659-2-mikel@mikelr.com> X-Mailer: git-send-email 2.13.7 In-Reply-To: <20200313222258.15659-1-mikel@mikelr.com> References: <20200313222258.15659-1-mikel@mikelr.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org pci_platform_rom() returns an __iomem pointer which should not be accessed directly. Change radeon_read_platform_bios() to use memcpy_fromio() instead of calling kmemdup() on the __iomem pointer. Signed-off-by: Mikel Rychliski --- drivers/gpu/drm/radeon/radeon_bios.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/radeon/radeon_bios.c b/drivers/gpu/drm/radeon/radeon_bios.c index c42f73fad3e3..c3ae4c92a115 100644 --- a/drivers/gpu/drm/radeon/radeon_bios.c +++ b/drivers/gpu/drm/radeon/radeon_bios.c @@ -118,11 +118,14 @@ static bool radeon_read_platform_bios(struct radeon_device *rdev) return false; } - if (size == 0 || bios[0] != 0x55 || bios[1] != 0xaa) { + rdev->bios = kzalloc(size, GFP_KERNEL); + if (!rdev->bios) return false; - } - rdev->bios = kmemdup(bios, size, GFP_KERNEL); - if (rdev->bios == NULL) { + + memcpy_fromio(rdev->bios, bios, size); + + if (size == 0 || rdev->bios[0] != 0x55 || rdev->bios[1] != 0xaa) { + kfree(rdev->bios); return false; }