From patchwork Thu Oct 5 00:53:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 9986173 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C681760291 for ; Thu, 5 Oct 2017 00:53:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B819128C43 for ; Thu, 5 Oct 2017 00:53:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ACBB928C45; Thu, 5 Oct 2017 00:53:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_HI,RCVD_IN_SORBS_SPAM autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 740BE28C43 for ; Thu, 5 Oct 2017 00:53:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753095AbdJEAxw (ORCPT ); Wed, 4 Oct 2017 20:53:52 -0400 Received: from mail-pg0-f43.google.com ([74.125.83.43]:53336 "EHLO mail-pg0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753093AbdJEAxv (ORCPT ); Wed, 4 Oct 2017 20:53:51 -0400 Received: by mail-pg0-f43.google.com with SMTP id y192so72976pgd.10 for ; Wed, 04 Oct 2017 17:53:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:mime-version:content-disposition; bh=ueL/QRAKGZNf1ysSWX0NbQHEiyjrbDnMGML8F4UmoPk=; b=IDIQ1FLyi97W0wTLoO9ZjHaIQnHCsXJaPvHVAqGrMcnMLivnkF1A/SkEag1Ha6wzk4 ctxUmHceQ4xMdpPv1r4JPVZjnHvz4nQ6XuCpniv1V/AB31crYUlY312cvX+HLT971BCU 6k2UzSWvydnkABa3g9yoH9NozcvwwZ7ps9PRs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=ueL/QRAKGZNf1ysSWX0NbQHEiyjrbDnMGML8F4UmoPk=; b=eazuEZJ8I+qkdsfQjYznQLse38PXb0NhAwIXzAZFh7wPA4G7nVA5bUIlT6nvbc64nI QxwJUAmc1WCOtykd2pJN75M+anX8+SCpsmQX54LvrjU/RsLTqb23iYQHV3CKaMsZWcyU 49LUBc61u9BWLT2/okTs2iDor0UOxcM/kQ/6dIj9SPtYjPZNE4VhqjaXKaVkx3NtgmKP RtC00IpHK79vtDbQCLDaXArWyR01ZQgLBmMzcqx4aGwqIU16ALhwR5ARHyI9GP+UtJz+ c1F7/YpudXa2JcPErj4KlqFYpkOtvE2gm4FpOf1EUwxjN2aQ+HqwJ7O1E0Wdgoh1MmXP Ba/Q== X-Gm-Message-State: AMCzsaXE+8JEoPOEH7dwihHNO4exAZ5xOp+/WJoZ+963gcBgZXcSNlOF 8Gb+l/EyOOmFwgQ7PZj6U9pgeQ== X-Google-Smtp-Source: AOwi7QD++Re40tg87z16idajVT0fpP5M9gN7lQZbWBaQQYX9Q1FVSSFdCSxWKkwdGfbUvjIPisbzrg== X-Received: by 10.98.30.66 with SMTP id e63mr6736843pfe.176.1507164830630; Wed, 04 Oct 2017 17:53:50 -0700 (PDT) Received: from www.outflux.net (173-164-112-133-Oregon.hfc.comcastbusiness.net. [173.164.112.133]) by smtp.gmail.com with ESMTPSA id r11sm29065576pfk.108.2017.10.04.17.53.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Oct 2017 17:53:49 -0700 (PDT) Date: Wed, 4 Oct 2017 17:53:48 -0700 From: Kees Cook To: linux-kernel@vger.kernel.org Cc: Bjorn Helgaas , Mika Westerberg , Mayurkumar Patel , Keith Busch , linux-pci@vger.kernel.org, Thomas Gleixner Subject: [PATCH] pci/ehp_hpc: Convert timers to use timer_setup() Message-ID: <20171005005348.GA23838@beast> MIME-Version: 1.0 Content-Disposition: inline Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In preparation for unconditionally passing the struct timer_list pointer to all timer callbacks, switch to using the new timer_setup() and from_timer() to pass the timer pointer explicitly. This fixes what appears to be a bug in passing the wrong pointer to the timer handler (address of ctrl pointer instead of ctrl pointer). Cc: Bjorn Helgaas Cc: Mika Westerberg Cc: Mayurkumar Patel Cc: Keith Busch Cc: linux-pci@vger.kernel.org Cc: Thomas Gleixner Signed-off-by: Kees Cook --- This requires commit 686fef928bba ("timer: Prepare to change timer callback argument type") in v4.14-rc3, but should be otherwise stand-alone. --- drivers/pci/hotplug/pciehp_hpc.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c index e5d5ce9e3010..ba5055c5115c 100644 --- a/drivers/pci/hotplug/pciehp_hpc.c +++ b/drivers/pci/hotplug/pciehp_hpc.c @@ -50,14 +50,13 @@ static irqreturn_t pcie_isr(int irq, void *dev_id); static void start_int_poll_timer(struct controller *ctrl, int sec); /* This is the interrupt polling timeout function. */ -static void int_poll_timeout(unsigned long data) +static void int_poll_timeout(struct timer_list *t) { - struct controller *ctrl = (struct controller *)data; + struct controller *ctrl = from_timer(ctrl, t, poll_timer); /* Poll for interrupt events. regs == NULL => polling */ pcie_isr(0, ctrl); - init_timer(&ctrl->poll_timer); if (!pciehp_poll_time) pciehp_poll_time = 2; /* default polling interval is 2 sec */ @@ -71,8 +70,6 @@ static void start_int_poll_timer(struct controller *ctrl, int sec) if ((sec <= 0) || (sec > 60)) sec = 2; - ctrl->poll_timer.function = &int_poll_timeout; - ctrl->poll_timer.data = (unsigned long)ctrl; ctrl->poll_timer.expires = jiffies + sec * HZ; add_timer(&ctrl->poll_timer); } @@ -83,7 +80,7 @@ static inline int pciehp_request_irq(struct controller *ctrl) /* Install interrupt polling timer. Start with 10 sec delay */ if (pciehp_poll_mode) { - init_timer(&ctrl->poll_timer); + timer_setup(&ctrl->poll_timer, int_poll_timeout, 0); start_int_poll_timer(ctrl, 10); return 0; } @@ -764,8 +761,7 @@ int pciehp_reset_slot(struct slot *slot, int probe) ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", __func__, pci_pcie_cap(ctrl->pcie->port) + PCI_EXP_SLTCTL, ctrl_mask); if (pciehp_poll_mode) - int_poll_timeout(ctrl->poll_timer.data); - + int_poll_timeout(&ctrl->poll_timer); return 0; }