From patchwork Tue Jun 4 09:38:42 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Holler X-Patchwork-Id: 248517 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail-bk0-x23d.google.com (mail-bk0-x23d.google.com [IPv6:2a00:1450:4008:c01::23d]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id D26BE2C0099 for ; Tue, 4 Jun 2013 19:44:29 +1000 (EST) Received: by mail-bk0-f61.google.com with SMTP id ik5sf1239209bkc.6 for ; Tue, 04 Jun 2013 02:44:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20120806; h=mime-version:x-beenthere:x-spam-checker-version:x-spam-level :x-spam-status:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-original-sender :x-original-authentication-results:reply-to:precedence:mailing-list :list-id:x-google-group-id:list-post:list-help:list-archive:sender :list-subscribe:list-unsubscribe:content-type; bh=f/7XMV65CaM0z/YB69jzqS7t0lapZhdB2S2GPinE50k=; b=RblsqEefpy7lMz8j+nNkecAMojhz4bpRkKG/tY9z8Zmp/msNDmrWosrkWSyUBaJtRR vES88wP85no5t0QF0xE6K8r9JXeSW8vdT/zoR/jrq6v9AZcAvmqScEYg5llCknJuvHwR DwdUXY2pI1w51UX45/eDk+mLaz+T2CASnO030oAlj/6oMHu8E8YZcYzOlkiIqGO64u/l gCbHNBXXjDtqlpkAiuDIgNZNo7LgcraduolRz5meDu+bI0uadchjVHzf3+cGtsPIJAMp IQz7MnqEMbeg8qi0WtIbv3ZWG5hpUNPrINXA+wPFIeovy3kVc4yB3iITU8MAC1zywkuB waPA== X-Received: by 10.180.198.199 with SMTP id je7mr34860wic.4.1370339064784; Tue, 04 Jun 2013 02:44:24 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: rtc-linux@googlegroups.com Received: by 10.180.83.40 with SMTP id n8ls1150178wiy.19.canary; Tue, 04 Jun 2013 02:44:24 -0700 (PDT) X-Received: by 10.15.101.142 with SMTP id bp14mr14786950eeb.7.1370339064264; Tue, 04 Jun 2013 02:44:24 -0700 (PDT) Received: from mail.ahsoftware.de (h1446028.stratoserver.net. [85.214.92.142]) by gmr-mx.google.com with ESMTP id o5si14640129eew.0.2013.06.04.02.44.24 for ; Tue, 04 Jun 2013 02:44:24 -0700 (PDT) Received-SPF: neutral (google.com: 85.214.92.142 is neither permitted nor denied by best guess record for domain of holler@ahsoftware.de) client-ip=85.214.92.142; Received: by mail.ahsoftware.de (Postfix, from userid 65534) id 963488880C3; Tue, 4 Jun 2013 11:44:23 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.ahsoftware.de X-Spam-Level: X-Spam-Status: No, score=-101.0 required=5.0 tests=ALL_TRUSTED, USER_IN_WHITELIST autolearn=disabled version=3.3.1 Received: from eiche.ahsoftware (p57B23C08.dip0.t-ipconnect.de [87.178.60.8]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.ahsoftware.de (Postfix) with ESMTPSA id 90FD68880C3 for ; Tue, 4 Jun 2013 11:44:21 +0200 (CEST) Received: by eiche.ahsoftware (Postfix, from userid 65534) id 75C0480C2C; Tue, 4 Jun 2013 11:44:20 +0200 (CEST) Received: from laptopahbt.ahsoftware (unknown [192.168.211.6]) by eiche.ahsoftware (Postfix) with ESMTP id EB8457F977; Tue, 4 Jun 2013 09:38:59 +0000 (UTC) From: Alexander Holler To: Andrew Morton Cc: linux-kernel@vger.kernel.org, rtc-linux@googlegroups.com, Alessandro Zummo , John Stultz , Alexander Holler Subject: [rtc-linux] [PATCH] rtc: rtc-hid-sensor-time: fix possible bug on driver_remove Date: Tue, 4 Jun 2013 11:38:42 +0200 Message-Id: <1370338722-3646-1-git-send-email-holler@ahsoftware.de> X-Mailer: git-send-email 1.8.1.5 In-Reply-To: <1367752887-2927-4-git-send-email-holler@ahsoftware.de> References: <1367752887-2927-4-git-send-email-holler@ahsoftware.de> X-Original-Sender: holler@ahsoftware.de X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 85.214.92.142 is neither permitted nor denied by best guess record for domain of holler@ahsoftware.de) smtp.mail=holler@ahsoftware.de Reply-To: rtc-linux@googlegroups.com Precedence: list Mailing-list: list rtc-linux@googlegroups.com; contact rtc-linux+owners@googlegroups.com List-ID: X-Google-Group-Id: 712029733259 List-Post: , List-Help: , List-Archive: Sender: rtc-linux@googlegroups.com List-Subscribe: , List-Unsubscribe: , The work we schedule on register deletes himself. Therefor we cannot use cancel_work_sync() because that calls flush_work() but still uses the pointer to the (now deleted) work afterwards (for clear_work_data) which ends up in a bug. Replacing cancel_work_sync() with flush_work() fixes that. Signed-off-by: Alexander Holler --- This patch applies on top of PATCH 3/4 or 4/4 of the small series of 4 patches for rtc-hid-sensor-time, which was already merged into the -mm tree. drivers/rtc/rtc-hid-sensor-time.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/rtc/rtc-hid-sensor-time.c b/drivers/rtc/rtc-hid-sensor-time.c index 4aca12d..acb2bc2 100644 --- a/drivers/rtc/rtc-hid-sensor-time.c +++ b/drivers/rtc/rtc-hid-sensor-time.c @@ -414,9 +414,8 @@ static int hid_time_remove(struct platform_device *pdev) struct hid_time_state *time_state = platform_get_drvdata(pdev); if (time_state->workts) { - cancel_work_sync(&time_state->workts->work); - kfree(time_state->workts); - time_state->workts = NULL; + flush_work(&time_state->workts->work); + BUG_ON(time_state->workts != NULL); } sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_TIME);