Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1405288pxu; Sat, 5 Dec 2020 15:19:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJzv16QWBBX72IKg3E8rdc12n9vgIP5b/ev0RZmrXFxybL1HGeEWikDckWMpn/O1AM83OuM0 X-Received: by 2002:a50:d884:: with SMTP id p4mr13661191edj.120.1607210368961; Sat, 05 Dec 2020 15:19:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607210368; cv=none; d=google.com; s=arc-20160816; b=y6pkKJP5N7ww/rTIektStwZjTxsf7+sGIQZAnS9NbbWWuREM1Y41d/UEwDk6RK/Zdm ubpK9d01unnkskmTn16E+tHh288gM2nv/lWMcbf7co70YbSjydJSojDVeY9obwTpHYdR 9ynxgN4iIR8Ynv/dP8XNJMrlHz7HUPWcw0pjuL1L4MubtsucMgzGlEn0oaW4+KrpfXNV RWs7STR3g/9TMSqbtraZD8Cn41kkcYjoEq8KrSsHycCEfQMg/THm7SAQLKkrwIujD1Mn kgzAtghto5bsX895yOdL6ISePj6ryPf7lFTwvJAgdwCYz3/aFqRJ2XrZjIYX67MbW6aC JMWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=mQCxxunMDrQi3lwKxxpTKRhYTfK96QYIjF9eQ5HfXQU=; b=AwRLOVqo/yXggqEjmnVOT+zAJAPfVcDX0VbFNo42ojdzSyF6QmTFBaXg+Mq3m8vzvl 6d7wtXLWsS7UIEQEI0AQZyze6A2GTSQgtZSnrjUAqW1lSe6SywAzdbECtUbUzut90LMJ A7HHjLSu29LpahClYnrLgiBaNYijgXVY+BRHjhjFzHwOFPb49yHWUncXo5U6R3KdBfa1 mKxz44/FfytMgjcwkFCh/Lkamq14w5DLweHB+L2sQb4Vt/3CcG82ALqX1odZfToGTdx8 kAl96vh44+1s0j5loCFJ11o8ON+3MTisVDaqwDFO0RjbAffQO9y06N0eOxrKtJsC5+pH E3YQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v16si3886469eja.188.2020.12.05.15.19.06; Sat, 05 Dec 2020 15:19:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726623AbgLEXPd (ORCPT + 99 others); Sat, 5 Dec 2020 18:15:33 -0500 Received: from relay9-d.mail.gandi.net ([217.70.183.199]:38935 "EHLO relay9-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726011AbgLEXPd (ORCPT ); Sat, 5 Dec 2020 18:15:33 -0500 X-Originating-IP: 86.194.74.19 Received: from localhost (lfbn-lyo-1-997-19.w86-194.abo.wanadoo.fr [86.194.74.19]) (Authenticated sender: alexandre.belloni@bootlin.com) by relay9-d.mail.gandi.net (Postfix) with ESMTPSA id 3D7DCFF802; Sat, 5 Dec 2020 23:14:51 +0000 (UTC) From: Alexandre Belloni To: Alessandro Zummo , Alexandre Belloni , Bartosz Golaszewski Cc: linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] rtc: fix RTC removal Date: Sun, 6 Dec 2020 00:14:48 +0100 Message-Id: <20201205231449.610980-1-alexandre.belloni@bootlin.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since the rtc_register_device, removing an RTC device will end with a refcount_t: underflow; use-after-free warning since put_device is called twice in the device tear down path. Fixes: fdcfd854333b ("rtc: rework rtc_register_device() resource management") Signed-off-by: Alexandre Belloni --- drivers/rtc/class.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/rtc/class.c b/drivers/rtc/class.c index e6b44b7c4ad3..5c6748dfa55d 100644 --- a/drivers/rtc/class.c +++ b/drivers/rtc/class.c @@ -335,7 +335,6 @@ static void devm_rtc_unregister_device(void *data) cdev_device_del(&rtc->char_dev, &rtc->dev); rtc->ops = NULL; mutex_unlock(&rtc->ops_lock); - put_device(&rtc->dev); } static void devm_rtc_release_device(void *res) -- 2.28.0