Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2267901pxu; Mon, 7 Dec 2020 01:54:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJwU/8qMTN6jXmTUU803kf9L0CI5QtR6KsMVntkC/Jh2XOnxylkBr4CaxEFZ1f9J8Jh7azEV X-Received: by 2002:a17:906:348b:: with SMTP id g11mr15148304ejb.12.1607334854474; Mon, 07 Dec 2020 01:54:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607334854; cv=none; d=google.com; s=arc-20160816; b=TtrH9pMML89C0IfktiqP4Cq7N1lg+6x+N/7YiCMNd5XejPt4w4BzQRnKHlTjSPatMx 8sira7ucRddGrqi4BMSmh7+wW6pr9vWmOFNtXKdwoQGjv3be+cmNYznpCGsuiPaDDw48 lc4D/LRoGTc3uhjrO3kVj3Pwp0ju9H4eWP0A2cWvB1ztygCiiPXbhyP96TJqoXsLbfOc 6jjWZOg2rGclCy7qB5gS5bjvfkBQp3wFbtAWZGhgRiQDw5GwFdKlLoJEbX7WT94k1hIf rWyX6DdUNSsG1J0LY0OEtb9070t/6yNQ4WAGzoLv+EzqPPD5Na2kGpbe+94m9xtubjPw ryGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=aDproOdcsujjsvAHCgcoIw5qD1NH0yafrww5RZ0rAYo=; b=iIoABDuDyxBY9ybsSIlYx9FMPG4CFeHP6OkRZlxb2nt/HeOpjlkXDBkiugOl4fcsWp weirkQoVfEbkuLGcyU10YCkCWfKbhfGFCOtBfMUt/oCkBYzJCAXwK+Dfz8FqCffFuCGK tiO/ibatiaHkPSfv9qVP6Mzde39/gnS85kGjqZCyVdSTqOzAL+FJhVZ6xmu/mCt/osRW x2kak1BGKJtIXulTynSNS7iN4t314A4ObVvxwxgG6alPtok9ynelEjcYeh/k7YptM5qd jHFxGj4yRjoJEokkuXBXELNo+Vn6Bam1nP0C5MsdLWTDO7UYwv5e3G7iDJOm4/izu/W1 pyWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b="v/lPNlrI"; 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 t1si7805758edy.153.2020.12.07.01.53.51; Mon, 07 Dec 2020 01:54:14 -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; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b="v/lPNlrI"; 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 S1726661AbgLGJwN (ORCPT + 99 others); Mon, 7 Dec 2020 04:52:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725852AbgLGJwM (ORCPT ); Mon, 7 Dec 2020 04:52:12 -0500 Received: from mail-ej1-x643.google.com (mail-ej1-x643.google.com [IPv6:2a00:1450:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 758F6C0613D1 for ; Mon, 7 Dec 2020 01:51:32 -0800 (PST) Received: by mail-ej1-x643.google.com with SMTP id a16so18592191ejj.5 for ; Mon, 07 Dec 2020 01:51:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=aDproOdcsujjsvAHCgcoIw5qD1NH0yafrww5RZ0rAYo=; b=v/lPNlrI+spy8ENH+siV8TRv9D/gzdb+wn2WpEVq6QujJsT6lP3ViRFQCgOYnAyaVP ouWFjVkBONwwhwcCZGEdxrTB9FPe4ts2NOCY1MuH6bM0Q/ujet6Rf0hJJDbuJDXBqRCA K1dXDnGLuoEsGh2mZq9xWwR1hQTcnlM/s6YDFRPJxbInvrXgi5WaKnwOi1MVind3zo3R AOaDclMHK91OSLU/fNgjh3Tni2jA8UJ91hmcRsC4JfprD4Kd1b6pSOqSXDr0UxMSqolC Jn3BPaYleMhQmUfQ0afwo9/u53/EzPZnq96+BoUThWLAVE8Oz6Eoc5vVFWvyAwWm//0K UvGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=aDproOdcsujjsvAHCgcoIw5qD1NH0yafrww5RZ0rAYo=; b=lG27MFIDF9jIH73lE4ooKq4xOKu2Zj4l01sxCsH3inZPzQnV3CNGshPRHjSqv2VkjW FF+mjdB1tbuSWIqGnRXlIgI8lUDiSpcWu6n9+TuLhPAklZ7vqFMdgyIxL70TwGA8DaKF Tu7YaxJ0x+szGiHEZy7djFGAxViiFIu9S4H7NtH66DuKDtZ+aWCYPFJNgSSdEo4Mt7Qq oDvSk3CD5CA5rPiT+jdPN8IFcGDb9hMJQgOSNECDty1/oiITPoSnTwG8481cHnPqU0Fu fGiZaZF3LeHIzKba54adSqk7U1c3CPU49BXs/SNo2lAfx9WpCKXkzWABvFJUWN2vnBKc 4USQ== X-Gm-Message-State: AOAM530fUoqKCUQMsZ9fYMRuSaHc33SiUoFDq+EK9GtDoqlOzx79U2AI TmzKm3u6p4X43Tv8fw+9yMQ9Ky1I2GQokIlEHr8xZ1IEgRs= X-Received: by 2002:a17:907:2179:: with SMTP id rl25mr17804481ejb.470.1607334691230; Mon, 07 Dec 2020 01:51:31 -0800 (PST) MIME-Version: 1.0 References: <20201205231449.610980-1-alexandre.belloni@bootlin.com> In-Reply-To: <20201205231449.610980-1-alexandre.belloni@bootlin.com> From: Bartosz Golaszewski Date: Mon, 7 Dec 2020 10:51:20 +0100 Message-ID: Subject: Re: [PATCH] rtc: fix RTC removal To: Alexandre Belloni Cc: Alessandro Zummo , linux-rtc@vger.kernel.org, LKML Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Dec 6, 2020 at 12:14 AM Alexandre Belloni wrote: > > 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 > Eek! Thanks for fixing that. Reviewed-by: Bartosz Golaszewski