From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.167.49 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796192886; b=zIkVKKyKkG1vJZ7+pZsVTkfDRPMbUJc1weplUUocBuiSOH2v+6VpQYbdv/knB5F368jp bPREKDPyfWo/pGYJtSCZcsTEm0S0WHZtjpdsJeVyPUTR/3BAQ/Yfgpl4sYwfpqmkRbsBX UdlZ2w8vZ42NYwVNJ1w9I1UBESdSmnmmGF9vnqMW0/GyX+/J9eWjy9RRujzot9ZnqHT7v MuzCXf9JtFiJvGtMP/RyHMlYJEXFqJn45bTkf7NMTExCWknSVPPfZPlZwbAkA+IDv2mO5 ese6futZPpSSNhqR7GiLkfHpknCfHujSjqAmgBn322v3RAKobfUxwV7Y/4UDwUm6Cig== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796192886; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Message-ID:Date:MIME-Version:User-Agent:Subject:To:Cc:References: Content-Language:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; bh=HPPYxl7BRN3Pe1VYDMB1cm2NffcdRWaMvAF7qGcPjZE=; b=IbF1cp8oC1ZSCbPjfuKqcIocOONVLm/IVKvL6T82yhzPrsux7ZYxPSimXIEh6HnRyYQ6 JNDY9EftWczUr9W3X/nxOkAlz+nbccEei9FtZi6v8U+FxbBik8t8Anmsiisi2VgY4iiWu OJozapJ3p52/YKsCFl1r0+tULE7YMIFZXZ8QzVyI1LpNFcnubjE+2J89ODfyHPDt4DGvo PhrzXTn23xdA4Tt0CdCffPvrsYOTcg6wnAcA0u8VtidtyJB2eRc2LgLIOCejrBkRprtzF 8BMbpUGOf+GVzZbFEM7n1oSEcFI2B8uQUHUJQ576t1hzzL1VailFt6grxUXTObID3Jw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=oIl5Xt73; arc=none smtp.remote-ip=209.85.167.49 Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C4C00606A334 for ; Wed, 2 Dec 2026 06:28:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C4C00606A334 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=oIl5Xt73 Received: by mail-lf1-f49.google.com with SMTP id 2adb3069b0e04-5c31369ae36so5360293e87.0 for ; Tue, 01 Dec 2026 22:28:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796192883; x=1796797683; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=HPPYxl7BRN3Pe1VYDMB1cm2NffcdRWaMvAF7qGcPjZE=; b=oIl5Xt739Sqxya4MCMdmgDhYPFOeZIMLBhlo9ERkrLnk6SQSze0t1Q9GkfFBcl3C0d ETVijN+Y+6Wm4p7d64YBXL845St++a1s2l5BTVYXcpCjKHHVNPSJVnLbY69kG5834bFl jAAkrI6KW/3Fr8VuY9Qn7rNteHJHddgcWT37pPny5VMEyNXtEeMmbENnD4tb6L2rebAy iVhi4YFvkaRH6/WLPJKF3KKL0nXHfaoc79AP2iieTeQ7UITZ1j9Or20/wg+m9HFsmVrk YbIP0RZlzqMxSyuJHYAK4S4pn2eWdKvoN6Z9mfDEjUDTfYVVOmWsqBO5RcLH0MJxbHwB Srdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796192883; x=1796797683; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=HPPYxl7BRN3Pe1VYDMB1cm2NffcdRWaMvAF7qGcPjZE=; b=T4VLH+WhyjSTlfaUk7O4WoV9wd9Qp7B7+3+HcWx1Y0jMNAomNmWKhCCN1PgyfaN9uX 4VXooBQljQjFzzHMXrw9rlJ0gH5t5xFvr0iL29iGJo33D537apkhbsvPepFKMOnb40wN NqhvsxV/RaEaiIClxbTbo87ofXOVVr9Ym1FdFn529IzXXTC8QAnCkmKRaCFw3gfNWvR6 qFYV/LSTWQtqs0sQ0EktMCd8SghB854A5ITVU4WWaJr3qhfvHRWJsQMP9hcSWcwpZ+uY UXa809nAATXkqiqG9T++kFQnFU3dH16RrZnLA3LCJ+OoeUdXkNlwaElszy6darWLzpdn Wisw== X-Forwarded-Encrypted: i=1; AL+hErEPE9ioaXgs18QyKbFMcfTPKm9YXykT8qWU5tjkq9EOJYiq+mp6g+Pw96GIB+2KQ1ZRACZnkf6zzoVC87myHQ==@vger.kernel.org X-Gm-Message-State: APuU4Z8WylxfKG88TYxT2l1vGGs4+0hjIkBlY3L8XfII3TU9cEDYtTdD GMbP5FfwAH+sycuUZis7FWmorveyKrbtt50hwaa5Al1T3piqjZINm5hj X-Gm-Gg: AZFdTZcj7IyQX5MBpz3fwJfn0rhYquQIKiO9a03ef9KDHukJsg90fWzcuRe7MqOgdC/ OhfvWB2BZNaZKFX6DgHs2LYZ8Fu8BaJr6rZ2T5KsEkFKsaxuoWl5zpPlDilVuT+y0nE/D2hjPbb fhWtyQRQ+LyhrIwIiL1lB59CcjPw52XIiF9ztcm1/HYIpX/5PTTEAs4XW5mh2Ocb2MsJRERH82f iW5JTk7fn1uCVO2TM4NgkNd/RYHPe/qv4PAF0AP3vd3ZrzR+/7/4nwWEimlNvFCrskihq9vzjUs tAq1BWEnqLw7pJC4JBpJnBGNAhBLHjHhbBR8ho5tv/xy/pAKMzY4bxISA+3LpXxA5aF2zz8oQxK xqt4Lmnbr54OsCtIPq2lCcB+LsyrI0AX91kQHaUr4rFIj+laKrG51lu75zozHsC+f4N3GHDZSb5 5Q85OAZ0UH0xgiOcfqmOzKkIYCOlrCv6hvmFsdenrMC4n2u6xlIDvX38bYJgndQTkeQ3ntgXlTA dk4L65NWg7IG6G4wCPL25tyjsbFhE9Jd/l/G5HpFMuy+rs0IrsX/5sZBJjYrqZsKH83c9RdGSik yIzeNOSf9DvZ/Wxpi7GRo0jYxjRykDBGhMpEyc6CaSXBE++ZyB2hh5KyTwTq+pP4Ya6m2r8NeTt eVnb1tEmg X-Received: by 2002:a05:6512:61aa:b0:5c1:57cd:5c3d with SMTP id 2adb3069b0e04-5c1bc806a59mr12151119e87.23.1796192883258; Tue, 01 Dec 2026 22:28:03 -0800 (PST) Received: from ?IPV6:2a10:a5c0:800d:dd00:8fdf:935a:2c85:d703? ([2a10:a5c0:800d:dd00:8fdf:935a:2c85:d703]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5c1bce3683csm9483628e87.0.2026.12.01.22.28.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 01 Dec 2026 22:28:01 -0800 (PST) Message-ID: Date: Wed, 2 Dec 2026 08:28:00 +0200 X-Mailing-List: linux-watchdog@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/5] watchdog: bd96801_wdt: Set .owner = THIS_MODULE in watchdog_ops To: Ian Rogers Cc: Guenter Roeck , Wim Van Sebroeck , Nathan Chancellor , linux-watchdog@vger.kernel.org, llvm@lists.linux.dev, linux-kernel@vger.kernel.org, Lee Jones References: <20261130225410.98349-1-irogers@google.com> <20261130225410.98349-3-irogers@google.com> <91a23265-b2ae-4ed0-9593-d31d19a62b72@gmail.com> <122533eb-1d79-44d9-85c2-5b7977f02f08@roeck-us.net> <58ddcba6-d1be-4c4c-987d-eb7170dc716b@gmail.com> Content-Language: en-US, en-AU, en-GB, en-BW From: Matti Vaittinen In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 01/12/2026 20:02, Ian Rogers wrote: > On Tue, Dec 1, 2026 at 9:43 AM Matti Vaittinen wrote: >> >> On 01/12/2026 19:19, Ian Rogers wrote: >>> On Tue, Dec 1, 2026 at 8:19 AM Guenter Roeck wrote: >>>> >>>> On 12/1/26 00:03, Matti Vaittinen wrote: >>>>> On 01/12/2026 00:54, Ian Rogers wrote: >>>>>> watchdog_open() calls try_module_get(wdd->ops->owner) to prevent the >>>>>> watchdog driver module from being unloaded while /dev/watchdog is open, >>>>>> and watchdog_release() calls module_put(wdd->ops->owner). Because >>>>>> try_module_get(NULL) succeeds without incrementing any module reference >>>>>> count, omitting .owner = THIS_MODULE allows the module to be unloaded >>>>>> while the watchdog character device is open. >>>>>> >>>>>> Set .owner = THIS_MODULE in bd96801_wdt_ops, found with Clang's >>>>>> require_explicit_initialization attribute. >>>>>> >>>>>> Fixes: 09dad69757b6 ("watchdog: ROHM BD96801 PMIC WDG driver") >>>>>> Signed-off-by: Ian Rogers >>>>> >>>>> Reviewed-by: Matti Vaittinen >>>>> >>>>> Thanks a lot! >>>>> >>>>> This made me wonder, would it be possible to do some macro-magic so the .owner was automatically set upon driver registration to wdg-core, when driver is built as a module? ... >>> For preventing missing .owner in struct watchdog_ops going forward: >>> __must_init (wrapping Clang's require_explicit_initialization attribute) >>> just landed in driver-core-next / linux-next for v7.5: >>> https://lore.kernel.org/lkml/20261119192520.1983406-1-irogers@google.com/ >>> >>> Once that reaches v7.5-rc1, adding __must_init to >>> struct watchdog_ops::owner will catch any driver that omits .owner at >>> compile time on Clang 20+, including built-in or unprobed drivers where >>> a runtime check on registration wouldn't catch a NULL owner. I can send >>> that one-line follow-up patch once the macro is in mainline. >> >> Does this work if there are drivers which can't be build as modules, and >> which are omitting the initialization (assuming that's allowed)? If yes, >> I am all for it. Do you know if there is a gcc equivalent? > > Sadly there isn't a gcc equivalent yet. With __must_init you can't Oh well, I suppose one can't have everything. This is still much better than nothing. > omit the initialization but you can initialize to NULL, which at least > requires a conscious decision that you want to omit the > initialization. You can use __must_init on structs in kernel and > module code. Sounds great to me. If I read Guenter's reply (to other mail in this thread) right, there aren't too many drivers which are built only in-kernel so requiring explicit initialization also for them doesn't sound bad to me. The whole __must_init addition sounds good to me. Thanks for the lesson, nice to have a new tool in the box :) Yours, -- Matti -- Matti Vaittinen Linux kernel developer at ROHM Semiconductor Oulu Finland ~~ When things go utterly wrong vim users can always type :help! ~~