Received: by 10.223.164.221 with SMTP id h29csp576476wrb; Tue, 24 Oct 2017 05:54:57 -0700 (PDT) X-Google-Smtp-Source: ABhQp+S9nRddZ+OB4QAi50kdQ0SqSnqTrdgZrUdPEJ05x5T9BIYbjCVJSuKDKkxsP9mqCAzrQIT+ X-Received: by 10.98.7.82 with SMTP id b79mr16340569pfd.289.1508849697186; Tue, 24 Oct 2017 05:54:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508849697; cv=none; d=google.com; s=arc-20160816; b=xOFwNLJVXZmhTzDMDs0SHW25nM0+wgn9FhxwgrWN88iSfjx0j+Z5FcydbvaGo6IBa+ 95h+a4Es6o8upW/uZDf9DDoDG68pplQsEGNiZrjhWW++RbWzxaXO3mgWleuaBndz1rHU Z2Fq7uN/VBajrcEikDegCP6w6kC07NrmhxgLwrl/UVwnWq0H8Si/lYr4i/u9y/7pANMB fJ7+qgbdD9z51zzgDW/CIHYw3ciDWSbP3US1PAxf0MNznKc3+/LF0c9C2jOtp8aKI5rz aEMsQefigYsV5cuFKweVqIiqQRNinBffm4hWPaiUcpniQjEBJSHqpXjuvOIBcjGlongh cTXg== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=062XkbguSt2tZSs0oM7JBg/ieJF7ljqvF9PZVuSS9fE=; b=PLRc3QUNGUQ+dNMsZXRSdHGQvMhx1a7ihtPB7CxzZpEWzatz9JoKjSACelx2o9meuD TSpf5vJMRUlLhlqBosrKSx/zJbJcyiD5xWxHxlPHiSVGqHs/ntSrRsuLXjIMLjpxUc7J YwSj0sp/MQNtHUsQLr9tvyRJw4ydIKMIOx8vSeij0Us4U/ZWF615k33moFdNpM8D2IM/ aA0SwcFTng5PD5NAlVL7GEQTwJzARugp2qy1yz24p/pq4u2KJ4ro1nOwK0tju+waMPV7 8yiVJqw860Ywl1Z1vsjHmhHQosnn+Gyt41gH/FzV5RUk4ofqM4KnvDVPULVvj3YEuej/ 6wkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nexus-software-ie.20150623.gappssmtp.com header.s=20150623 header.b=vAi52rF0; 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 70si129604ple.7.2017.10.24.05.54.43; Tue, 24 Oct 2017 05:54:57 -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=@nexus-software-ie.20150623.gappssmtp.com header.s=20150623 header.b=vAi52rF0; 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 S932539AbdJXMwy (ORCPT + 99 others); Tue, 24 Oct 2017 08:52:54 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:52725 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932376AbdJXMww (ORCPT ); Tue, 24 Oct 2017 08:52:52 -0400 Received: by mail-wm0-f66.google.com with SMTP id 78so13233816wmb.1 for ; Tue, 24 Oct 2017 05:52:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nexus-software-ie.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=062XkbguSt2tZSs0oM7JBg/ieJF7ljqvF9PZVuSS9fE=; b=vAi52rF0LqLMCWendjbOpXG09tZPf/On72SDUy96aP5AILRpeU9pV2TrHjCA3yyRQP ffghGg2nRNou+4AHDcflt+G1rXMtNWp4YaGV2MjYcvSeOb+bN6dbqE5LlR6LkaCKkwUB 4q4FwOpZbEegizd9wmC3562BdjY5+mTtkYBr6L5AzWkZYiUqs+b9OYm/PiyHFeLAL1uE 3cB+cb+GbVRqQyRgLNYq5dZgiGHwGxpxu88edyWs2DI1t8YwGsopiDV4/frh2yG3D6zh gCiIW0DAEydRw47VV0FoO8/R9pS9HEdReXoqZXcOIa3YsselSaTo1iJspdtvjO8Ban0O Qc6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=062XkbguSt2tZSs0oM7JBg/ieJF7ljqvF9PZVuSS9fE=; b=L5Ih7cencQLjk+44+06gaYjhg563HdUo2D+o1HLViEEPrji/H8iOz3GkIYG3d3Lkcv fb1V0K13AG9Ns6kLdGpzcEFkoc9dciXsq4acvXBK08lJZr0+6Rv/WIpQA67O1jDy6NuB vyJMPWL7vNBZc1Kf6z/KQoU2FLQKNyKIGsXKnL6ynpBqw5itLR1AezN/yfY34cIAhtXi 1JSMKyYyMvu3Gfalvqr7X4fvgLfGHy2fN827GCbFJyD2Bji89S3LNvcasuoYs9p2JAzz aX3+BA9MDWi/G4/R+YcCa/zecCc4rGVMUChn5IPnyr7DV3qI0eKOmPgozJSTYdda/0yG iGVQ== X-Gm-Message-State: AMCzsaUnC+Mp3mvYTcE2UsSd2TTwFd7UggWDM3DttV59euer3zncF/3l yITlwkLOxxXw8zHdtASsJimVmuuvofE= X-Received: by 10.80.243.21 with SMTP id p21mr11440456edm.38.1508849571281; Tue, 24 Oct 2017 05:52:51 -0700 (PDT) Received: from [192.168.192.35] ([109.255.42.2]) by smtp.gmail.com with ESMTPSA id i6sm180677edk.3.2017.10.24.05.52.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Oct 2017 05:52:50 -0700 (PDT) Subject: Re: [PATCH] staging: greybus: Convert timers to use timer_setup() To: Kees Cook Cc: Greg Kroah-Hartman , Johan Hovold , Alex Elder , greybus-dev@lists.linaro.org, devel@driverdev.osuosl.org, LKML References: <20171024082550.GA142933@beast> <3caa07a1-4f46-d879-cfec-586addc006af@nexus-software.ie> <42078a19-4922-3efe-8515-99cf6296ceed@nexus-software.ie> From: Bryan O'Donoghue Message-ID: <20c510b6-345d-06b0-e559-d781a307b7d2@nexus-software.ie> Date: Tue, 24 Oct 2017 13:52:50 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 24/10/17 13:47, Kees Cook wrote: > On Tue, Oct 24, 2017 at 2:40 AM, Bryan O'Donoghue > wrote: >> On 24/10/17 10:35, Bryan O'Donoghue wrote: >>> >>> On 24/10/17 09:25, Kees Cook wrote: >>>> >>>> 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. >>>> >>>> Cc: Greg Kroah-Hartman >>>> Cc: "Bryan O'Donoghue" >>>> Cc: Johan Hovold >>>> Cc: Alex Elder >>>> Cc: greybus-dev@lists.linaro.org >>>> Cc: devel@driverdev.osuosl.org >>>> Signed-off-by: Kees Cook >>>> --- >>>> drivers/staging/greybus/loopback.c | 14 ++++---------- >>>> drivers/staging/greybus/operation.c | 7 +++---- >>>> 2 files changed, 7 insertions(+), 14 deletions(-) >>>> >>>> diff --git a/drivers/staging/greybus/loopback.c >>>> b/drivers/staging/greybus/loopback.c >>>> index 08e255884206..045aaf81113a 100644 >>>> --- a/drivers/staging/greybus/loopback.c >>>> +++ b/drivers/staging/greybus/loopback.c >>>> @@ -572,16 +572,11 @@ static void gb_loopback_async_operation_work(struct >>>> work_struct *work) >>>> gb_loopback_async_operation_put(op_async); >>>> } >>>> -static void gb_loopback_async_operation_timeout(unsigned long data) >>>> +static void gb_loopback_async_operation_timeout(struct timer_list *t) >>>> { >>>> - struct gb_loopback_async_operation *op_async; >>>> - u16 id = data; >>>> + struct gb_loopback_async_operation *op_async = >>>> + from_timer(op_async, t, timer); >>>> - op_async = gb_loopback_operation_find(id); >>>> - if (!op_async) { >>>> - pr_err("operation %d not found - time out ?\n", id); >>>> - return; >>>> - } >>> >>> >>> Hi Kees, you need to add >>> >>> gb_loopback_async_operation_get(op_async); when dropping the >>> gb_loopback_operation_find() call here. >> >> >> Actually: >> >> spin_lock_irqsave(&gb_dev.lock, flags); >> gb_loopback_async_operation_get(op_async); >> spin_unlock_irqrestore(&gb_dev.lock, flags); > > Shouldn't the get/put follow the lifetime of the timer running > instead? It shouldnt' be possible to free the op_async while the timer > is still pending/running. > > -Kees > The timeout timer runs for an operation that never completed but on the regular "everything is good" path you end up doing del_timer_sync(&op_async->timer); so the timer doesn't run. From 1582143208968459542@xxx Tue Oct 24 12:49:03 +0000 2017 X-GM-THRID: 1582126742408023281 X-Gmail-Labels: Inbox,Category Forums