Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp239317ybi; Wed, 29 May 2019 20:25:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqzlznb1C6WwkFIa+89V7wm+dNYqq6K/zm35ty8cemb3kwiigp0Es2lJz0MtLTx880S0k9yN X-Received: by 2002:a17:902:22e:: with SMTP id 43mr1593502plc.272.1559186730499; Wed, 29 May 2019 20:25:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559186730; cv=none; d=google.com; s=arc-20160816; b=uL/hsg0MlVdGQGg4gd+mvodpODTJdivp1HAThLJ8mGsCEBwjEBGjIKwOaX5MHNzyHY fFpAMVWtfHWkZWsCGcVxn8HYyn+mRvADhbzP3Ilvsj+l7oDrRMWMZ9nsmQeIgsHxNOIt vhinaA24LCobXh3AyNqAjvE5kOcD1MxS61tf9mt+iLjUBmS+iViIe74TJHYcBCAb+UOi Ma32pY5BY6tkRBcq0XTpCbys6P/bW1glhpY38Vm1GyyFI4/MMpVvClIBaRSRB2gOGj6k TckhsGJjDojDEhrkSfIzH3Ng7zdPG/jBtxBE1TN+414qk4oZLk/P3gZxyFKAcyvhZIny c3dg== 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=Cz/wOZcLhYeAf4zneXRl3PjY5MaJbLSbzKIvn1A5Uzk=; b=eK69EXOHqLEpYJWUCe1a7EUi8ROvvmJ1fiNf9yTeb3mxgpwPBx3exy2wGpNihlLP4Q TwDxdYSgd7kEQ9o8eQcPfkZaXcEyzFr+GKj8KUYPu9olkjjakH4jAgq0H7d1O7xuo9ea tHXfVVKyW1Gimmtb/OtSlpeulgIwU27gKtrSaq/iLmst2YY7DX+CwZw9PnJsmyb54nkL 2IFQodgbt/AomHjLe/BXRcdvTr8/JXv+atLG7uibqqX4C/jfuH9YhXpXs4oeAP5rN/Fi iydT5Ca5A2X9515KVk1y7JU0bzU6IvROa6WSyJDSBuNjqR1byYa1xrgHrsa9F9HWpRpl g5Gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="2kYaiLQ/"; 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 u10si1565636pjr.102.2019.05.29.20.25.14; Wed, 29 May 2019 20:25:30 -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="2kYaiLQ/"; 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 S1731720AbfE3DX0 (ORCPT + 99 others); Wed, 29 May 2019 23:23:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:46748 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731100AbfE3DRZ (ORCPT ); Wed, 29 May 2019 23:17:25 -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 A4B1824479; Thu, 30 May 2019 03:17:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559186244; bh=zabL5YfqfgkOhrTRcXafw5T08OQA8mRkWoJ70DYQGDc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2kYaiLQ/8h7V4PaO4FrXzoknc7RjRjyPWajsU90Ye0tn/+AMqEhHoEz0vC60GEhOn mjrMf+Ro6x+irTkrdk87GnJlrwEB0ASHSS3G7RPls23YtEIBlYXGRQJ4nn/KIj2aHl gIIIOuu+go9PbpleR/xQ5WlIqpKhBTpIS+Cy+Tws= 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 159/276] hwmon: (smsc47b397) Use request_muxed_region for Super-IO accesses Date: Wed, 29 May 2019 20:05:17 -0700 Message-Id: <20190530030535.446686774@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 8c0826756744c0ac1df600a5e4cca1a341b13101 ] Super-IO accesses may fail on a system with no or unmapped LPC bus. 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: 8d5d45fb1468 ("I2C: Move hwmon drivers (2/3)") 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/smsc47b397.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/hwmon/smsc47b397.c b/drivers/hwmon/smsc47b397.c index 6bd2007565603..cbdb5c4991ae3 100644 --- a/drivers/hwmon/smsc47b397.c +++ b/drivers/hwmon/smsc47b397.c @@ -72,14 +72,19 @@ static inline void superio_select(int ld) superio_outb(0x07, ld); } -static inline void superio_enter(void) +static inline int superio_enter(void) { + if (!request_muxed_region(REG, 2, DRVNAME)) + return -EBUSY; + outb(0x55, REG); + return 0; } static inline void superio_exit(void) { outb(0xAA, REG); + release_region(REG, 2); } #define SUPERIO_REG_DEVID 0x20 @@ -300,8 +305,12 @@ static int __init smsc47b397_find(void) u8 id, rev; char *name; unsigned short addr; + int err; + + err = superio_enter(); + if (err) + return err; - superio_enter(); id = force_id ? force_id : superio_inb(SUPERIO_REG_DEVID); switch (id) { -- 2.20.1