Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp250675ybi; Wed, 29 May 2019 20:39:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqylZKgVJ23EvKiGlqtCvAgxkPV/cWTf18rUvODbLpt9DXj9zL2GnJ4BbjsCuEgYaKJqHZvw X-Received: by 2002:a63:78cf:: with SMTP id t198mr1685923pgc.82.1559187566028; Wed, 29 May 2019 20:39:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559187566; cv=none; d=google.com; s=arc-20160816; b=vcSvFtwJwwahg1u3BZHabRUhdQnyhZbXrXXYo1Itf/nv00NHB4r/geed7jM/reH6ER fjHomF6+IgywY2w/vdccXB+1VcUwObElhwyF/YcK/oyFfucu84mRMguxuUITekpuGo6x ZohBb73Ngi3GQVGO/nAe5+CX0RR/J4eAUvbicVPeQ3XqW+y8O1hUjdnJBC/SXvdtBxsr kCbLjD7WRVo4PQbhPMymh09zjeEjN14JVy0FOZw6Iaq9JipkFLTUWCENqx5I3o+fanhp ByEB+ngnj18F7PbPCEFwCqMydO+OrHvbzl5VvkMuUpn58LlIW9IlOFrDMIstYfFzeWvM 4Z2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=0XcFHxiRgVNflhd6AShID+5iFGmeSkMMueMapDfoyVk=; b=RvmVgKlcl7Vh6lbWvbfjRvENJTQa7MblqL8AmbBATJcpCvD33aXu9yk1V7nDifX6qz VBvJSTvbJyPXLW5nAvXbUkyT8i3QwHNqorUMyQxB1jn69VvjE/3jCtXy3bPQnZYsFYjr dA7SwEihHGE8VriH962YS3d1gP4f6zNaRk3lnbWhy2HyUcfJq3rM/ULAf5fedDHfkv/2 V5LytnAQCVPafmR9Z4OPGiEHOO0stlWLqmYmgI+XqeLysJEA0H7kKNqdeItfTSlgiUbH uqhRE43QfVhHNhciydnQVEv6SORr7Uii0FBFOOB3/qWBCvCFagiWaDXLSxaASxP6sQz9 rfZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vUD+svUT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z124si2288305pfz.93.2019.05.29.20.39.09; Wed, 29 May 2019 20:39:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vUD+svUT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730674AbfE3DXf (ORCPT + 99 others); Wed, 29 May 2019 23:23:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:46964 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731104AbfE3DR0 (ORCPT ); Wed, 29 May 2019 23:17:26 -0400 Received: from localhost (ip67-88-213-2.z213-88-67.customer.algx.net [67.88.213.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AE885244CC; Thu, 30 May 2019 03:17:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559186245; bh=KP7lvIFijuAn26mjaA5TFZqQkhkHwDao4ZgML5cbYZg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vUD+svUTntoACBzcIz9YztmuFtOFqHh6/6Uksd8S6znC3dICpvPrq9w5BgR+WMcbd qSk4opV4eNkhZVeSYe5EJ3Mf+6LBwFpeL6dMdsXducU4pu3GlqmHXT4hxGPf3td+QZ C5JR2+ULQWU7/IG4xgaqE0ewDeh/4EemFMliEH9U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kefeng Wang , John Garry , Guenter Roeck , Sasha Levin Subject: [PATCH 4.19 161/276] hwmon: (f71805f) Use request_muxed_region for Super-IO accesses Date: Wed, 29 May 2019 20:05:19 -0700 Message-Id: <20190530030535.551337511@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190530030523.133519668@linuxfoundation.org> References: <20190530030523.133519668@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 73e6ff71a7ea924fb7121d576a2d41e3be3fc6b5 ] Super-IO accesses may fail on a system with no or unmapped LPC bus. Unable to handle kernel paging request at virtual address ffffffbffee0002e pgd = ffffffc1d68d4000 [ffffffbffee0002e] *pgd=0000000000000000, *pud=0000000000000000 Internal error: Oops: 94000046 [#1] PREEMPT SMP Modules linked in: f71805f(+) hwmon CPU: 3 PID: 1659 Comm: insmod Not tainted 4.5.0+ #88 Hardware name: linux,dummy-virt (DT) task: ffffffc1f6665400 ti: ffffffc1d6418000 task.ti: ffffffc1d6418000 PC is at f71805f_find+0x6c/0x358 [f71805f] Also, other drivers may attempt to access the LPC bus at the same time, resulting in undefined behavior. Use request_muxed_region() to ensure that IO access on the requested address space is supported, and to ensure that access by multiple drivers is synchronized. Fixes: e53004e20a58e ("hwmon: New f71805f driver") Reported-by: Kefeng Wang Reported-by: John Garry Cc: John Garry Acked-by: John Garry Signed-off-by: Guenter Roeck Signed-off-by: Sasha Levin --- drivers/hwmon/f71805f.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/hwmon/f71805f.c b/drivers/hwmon/f71805f.c index 73c681162653b..623736d2a7c1d 100644 --- a/drivers/hwmon/f71805f.c +++ b/drivers/hwmon/f71805f.c @@ -96,17 +96,23 @@ superio_select(int base, int ld) outb(ld, base + 1); } -static inline void +static inline int superio_enter(int base) { + if (!request_muxed_region(base, 2, DRVNAME)) + return -EBUSY; + outb(0x87, base); outb(0x87, base); + + return 0; } static inline void superio_exit(int base) { outb(0xaa, base); + release_region(base, 2); } /* @@ -1561,7 +1567,7 @@ static int __init f71805f_device_add(unsigned short address, static int __init f71805f_find(int sioaddr, unsigned short *address, struct f71805f_sio_data *sio_data) { - int err = -ENODEV; + int err; u16 devid; static const char * const names[] = { @@ -1569,8 +1575,11 @@ static int __init f71805f_find(int sioaddr, unsigned short *address, "F71872F/FG or F71806F/FG", }; - superio_enter(sioaddr); + err = superio_enter(sioaddr); + if (err) + return err; + err = -ENODEV; devid = superio_inw(sioaddr, SIO_REG_MANID); if (devid != SIO_FINTEK_ID) goto exit; -- 2.20.1