Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6091186imu; Sun, 2 Dec 2018 09:49:57 -0800 (PST) X-Google-Smtp-Source: AFSGD/XS+h1CQ9hfRlqsGBLG69KUGP0pCKUKm8YbyCie7/PrUuRvcTddL97FS3BFFp93Le3hyD6c X-Received: by 2002:a17:902:29ab:: with SMTP id h40mr12922355plb.238.1543772997825; Sun, 02 Dec 2018 09:49:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543772997; cv=none; d=google.com; s=arc-20160816; b=IDdmtfheotgc8X4qSYE4kvczR5Ft/2lJVfM56nuwnUbu49ANPEVTN3rd9ynnikUjHx rzX8LoyAaMAnQ7oiRMiRcUiD50H/BAbs0pcCzEi0JKdLR3k6rGho1sj/nY8a6v143Xyl QpkzqgJ3GekMcNbBgtPVO0pODG4COycmNk/aU2CSZm3qEXcNHKzU890kAuc4ywA9jqd0 b4nla/ulshtTOvvWyunvMdoG827x30hloYQohmamcRglymohUsjyqGsCPXbZxf3nk5ia B2v3riqzcPsHhmvANN4PdXGKpW161FbAdLmpj877sP33BPjLjMM/hKJh4QdOCT9AST/q sNwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=49bskcZkUJXAp2I9Y2SM/899ZrR0sdi2zLdZ030oGsk=; b=UhRzVKknELyHCQ0Q/DMTrqRiGyOBAiPYcYeR4zVqDX77t4WjhUvZEUpyWDmB1UHGFH LLytB4z/mas0M8qZu3NUmYy2OISjobT4306pmzgreJOCeBKrPrhYWNFMMvZGtvRI2TdG pF5x4CYGTBNVcR8V6QCDrqrsgF++g17KrDZZ6ABMVxKq5jvSGDHVfnKb2xp1gaJByX/3 77psIg/Ef/fs5MxRw79a/xAfW/2Keio4ElCFvdNY0UV0EA0bz1qGLaIu54mjSJA22teT MqWPtC0Ms/IZN6oy8AQyzst7GNn4i1pwCEDXtCFrl4479AS9f9SSBfiWuw/uVsNrzcLl XyUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=LHFKc3hy; 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 11si10550907pgy.408.2018.12.02.09.49.40; Sun, 02 Dec 2018 09:49:57 -0800 (PST) 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=@messagingengine.com header.s=fm1 header.b=LHFKc3hy; 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 S1725788AbeLBRtF (ORCPT + 99 others); Sun, 2 Dec 2018 12:49:05 -0500 Received: from out4-smtp.messagingengine.com ([66.111.4.28]:56557 "EHLO out4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725613AbeLBRtF (ORCPT ); Sun, 2 Dec 2018 12:49:05 -0500 Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 8D03021ACE; Sun, 2 Dec 2018 12:49:01 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute7.internal (MEProxy); Sun, 02 Dec 2018 12:49:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:in-reply-to :message-id:references:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=49bskc ZkUJXAp2I9Y2SM/899ZrR0sdi2zLdZ030oGsk=; b=LHFKc3hynhvMPay/636TzU 34ZRWKfd3Wg9LEezSHkj6UkQXvwiholW6znHnihaQhOXIvrhJb8Wys13ViRAgQOE 9HUDrMqhwIvpcL+W7LcwjQSurRsUKyZ/cRJhp5UessQad2IY9dXiTbAaUMWmUNDq pFUKfALZwdK5P/7zslZTrW1qXDj2FiY49YnuWdUwKyPfxgvqLBbHR5HkqJayrNVB UVQPiRRWUrN/5tla1aF+syfw9RlMDE6jM3cQY84O8wNhoPZtDbrRUJ4C/wXzIvwe HzvZwqnWy8gSg7ET9mEK7qGr6EayrqJLtvtSNFkal1pvFALpMS7ChMJZkf216v8Q == X-ME-Sender: X-ME-Proxy: Received: from localhost.localdomain (ip5b40a57c.dynamic.kabel-deutschland.de [91.64.165.124]) by mail.messagingengine.com (Postfix) with ESMTPA id 3D88DE4535; Sun, 2 Dec 2018 12:49:00 -0500 (EST) From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= To: Boris Ostrovsky , Juergen Gross , Stefano Stabellini Cc: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= , Dwayne Litzenberger Subject: [PATCH 1/2] xen-pciback: Fix error return in bar_write() and rom_write() Date: Sun, 2 Dec 2018 18:47:32 +0100 Message-Id: X-Mailer: git-send-email 2.17.2 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dwayne Litzenberger Signed-off-by: Dwayne Litzenberger --- drivers/xen/xen-pciback/conf_space_header.c | 24 ++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/drivers/xen/xen-pciback/conf_space_header.c b/drivers/xen/xen-pciback/conf_space_header.c index 10ae24b..697d0a8 100644 --- a/drivers/xen/xen-pciback/conf_space_header.c +++ b/drivers/xen/xen-pciback/conf_space_header.c @@ -135,6 +135,7 @@ static int command_write(struct pci_dev *dev, int offset, u16 value, void *data) static int rom_write(struct pci_dev *dev, int offset, u32 value, void *data) { + int err = 0; struct pci_bar_info *bar = data; if (unlikely(!bar)) { @@ -150,17 +151,22 @@ static int rom_write(struct pci_dev *dev, int offset, u32 value, void *data) bar->which = 1; else { u32 tmpval; - pci_read_config_dword(dev, offset, &tmpval); + err = pci_read_config_dword(dev, offset, &tmpval); + if (err) + goto out; if (tmpval != bar->val && value == bar->val) { /* Allow restoration of bar value. */ - pci_write_config_dword(dev, offset, bar->val); + err = pci_write_config_dword(dev, offset, bar->val); + if (err) + goto out; } bar->which = 0; } /* Do we need to support enabling/disabling the rom address here? */ - return 0; +out: + return err; } /* For the BARs, only allow writes which write ~0 or @@ -169,6 +175,7 @@ static int rom_write(struct pci_dev *dev, int offset, u32 value, void *data) */ static int bar_write(struct pci_dev *dev, int offset, u32 value, void *data) { + int err = 0; struct pci_bar_info *bar = data; unsigned int pos = (offset - PCI_BASE_ADDRESS_0) / 4; const struct resource *res = dev->resource; @@ -193,15 +200,20 @@ static int bar_write(struct pci_dev *dev, int offset, u32 value, void *data) bar->which = 1; else { u32 tmpval; - pci_read_config_dword(dev, offset, &tmpval); + err = pci_read_config_dword(dev, offset, &tmpval); + if (err) + goto out; if (tmpval != bar->val && value == bar->val) { /* Allow restoration of bar value. */ - pci_write_config_dword(dev, offset, bar->val); + err = pci_write_config_dword(dev, offset, bar->val); + if (err) + goto out; } bar->which = 0; } - return 0; +out: + return err; } static int bar_read(struct pci_dev *dev, int offset, u32 * value, void *data) -- git-series 0.9.1