From patchwork Fri Dec 6 13:48:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Nuernberger X-Patchwork-Id: 11276489 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F2060109A for ; Fri, 6 Dec 2019 14:19:09 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CE2A320707 for ; Fri, 6 Dec 2019 14:19:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="LTEJgQ5t" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CE2A320707 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1idEQn-0007z4-Pv; Fri, 06 Dec 2019 14:18:05 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1idDyn-0005YT-NA for xen-devel@lists.xenproject.org; Fri, 06 Dec 2019 13:49:09 +0000 X-Inumbo-ID: 2c1b27af-182f-11ea-8256-12813bfff9fa Received: from smtp-fw-33001.amazon.com (unknown [207.171.190.10]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 2c1b27af-182f-11ea-8256-12813bfff9fa; Fri, 06 Dec 2019 13:49:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1575640149; x=1607176149; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=yg/H4rYLdpjMh9EeUO9p3gNSwplJDxuqHR+8symDg3A=; b=LTEJgQ5tm4ht+lT8CsKEFqzJS0qYquI4zxI/w20qqP3SpfM3NV5wRvbh P/A1iDAI6KS00Jsa+VlZP6jQHfehrb1VBeKUKjh+Y+C8Tj3yHcvcxiY1o xsgUI9A+U41WJuh0f2QA6wzD8htECy+JNlj5NGq8zsyMyTEtYII4ET3a8 c=; IronPort-SDR: FjhXB9JqAJI6AnLIvtS0fINmoBUIYUcB+9FSmhw7O7H4zkwx4pPwr7ol9WV7YDYF8GNVE7iwSL 9QljUSXCPItg== X-IronPort-AV: E=Sophos;i="5.69,284,1571702400"; d="scan'208";a="13388569" Received: from sea32-co-svc-lb4-vlan3.sea.corp.amazon.com (HELO email-inbound-relay-2b-c300ac87.us-west-2.amazon.com) ([10.47.23.38]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP; 06 Dec 2019 13:48:57 +0000 Received: from EX13MTAUEA001.ant.amazon.com (pdx4-ws-svc-p6-lb7-vlan2.pdx.amazon.com [10.170.41.162]) by email-inbound-relay-2b-c300ac87.us-west-2.amazon.com (Postfix) with ESMTPS id 6334EA2BE3; Fri, 6 Dec 2019 13:48:56 +0000 (UTC) Received: from EX13D07EUB004.ant.amazon.com (10.43.166.234) by EX13MTAUEA001.ant.amazon.com (10.43.61.243) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Fri, 6 Dec 2019 13:48:55 +0000 Received: from u86a60e9fba0b55.ant.amazon.com (10.43.162.16) by EX13D07EUB004.ant.amazon.com (10.43.166.234) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Fri, 6 Dec 2019 13:48:51 +0000 From: Stefan Nuernberger To: Date: Fri, 6 Dec 2019 14:48:04 +0100 Message-ID: <20191206134804.4537-1-snu@amazon.com> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 X-Originating-IP: [10.43.162.16] X-ClientProxiedBy: EX13D04UWB004.ant.amazon.com (10.43.161.103) To EX13D07EUB004.ant.amazon.com (10.43.166.234) Precedence: Bulk X-Mailman-Approved-At: Fri, 06 Dec 2019 14:18:04 +0000 Subject: [Xen-devel] [PATCH] xen/pciback: Prevent NULL pointer dereference in quirks_show X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Stefan Nuernberger , Conny Seidel , Ross Lagerwall , stable@vger.kernel.org, xen-devel@lists.xenproject.org, Boris Ostrovsky , Uwe Dannowski Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Uwe Dannowski Reading /sys/bus/pci/drivers/pciback/quirks while unbinding can result in dereferencing a NULL pointer. Instead, skip printing information about the dangling quirk. Reported-by: Conny Seidel Signed-off-by: Uwe Dannowski Signed-off-by: Stefan Nuernberger Cc: xen-devel@lists.xenproject.org Cc: stable@vger.kernel.org --- drivers/xen/xen-pciback/pci_stub.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/xen/xen-pciback/pci_stub.c b/drivers/xen/xen-pciback/pci_stub.c index 097410a7cdb7..da725e474294 100644 --- a/drivers/xen/xen-pciback/pci_stub.c +++ b/drivers/xen/xen-pciback/pci_stub.c @@ -1346,6 +1346,8 @@ static ssize_t quirks_show(struct device_driver *drv, char *buf) quirk->devid.subdevice); dev_data = pci_get_drvdata(quirk->pdev); + if (!dev_data) + continue; list_for_each_entry(cfg_entry, &dev_data->config_fields, list) { field = cfg_entry->field;