From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932544AbdJXMwy (ORCPT ); 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 X-Google-Smtp-Source: ABhQp+SSzJH8RCKPW1TX+C75QeBgcaJ1cBpVCGc4JvIFPk/3VurvSKa1VHYoJFIg8h9o5UE77JtEbA== 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 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.