From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.167.51 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796192885; b=QMqMSIS309kmpsWgQv8ZQJ90Lpjxviln1B/tmpp/Q5mvGX5JLL59Tl56QAf6a+NPtDdN J0q6KTIb/Bsx8srfH/oXGR+fFg8u8v3Z+6y/tbmm1BibAH3+PzO07xMHYRuV/PrH9rk6f rEieA1i/2Wfmf3lSVV9X/UgrdnsnSK4jcxZlbiBK33m5umdRFTDebT/wRN1wDKjN7y0WV fqlEqMEPCgcXV+omQSlqdTPCcu+WiHn7iC2Dfu3CBwTfA0fFcqBQ00cIkkfeKTQcLEHT1 1xx9KU/fwhFUI9MZVvQPMNTRudtuEMel37nP6x87hPhDrD/iST1gEGSlEltlVAw/c/Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796192885; 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=2i9IkwI6I2ipddqIQypy7aJpbmoCSJV0EKjPkRg0tmZ4F1pY6KmcOKMlHUAlogJq+T+o 6ViiFZiB9Qrb5EWOmRT/3lVds/j2idxAQ3NeHXeFP5rLRQ0xX1uqC53JVPw2nDI9ojqnF TzIx3h38s8O1Gi/Ld3IrSwcB6UwL7xarqLWy3hzb4AFTyBrUfuOrqjWjy/psf1fAXrPBM xXUnxIZ1VUeiPamoDhlPup0lVDwu78+ctHVdZI/TJc5iyb1HQLr6z1cq0rx9nuPHyNqr/ 2ClUstK2/LNlQGkKkMBt4yXEGNHfShbyxlvmIbIASwDrcWsT4jcElJi0Xvz6VXp7hkQ== 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.51 Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.51]) (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 54FC3606A32F for ; Wed, 2 Dec 2026 06:28:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 54FC3606A32F 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-f51.google.com with SMTP id 2adb3069b0e04-5c08539c827so9998923e87.2 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=B4y/gZ5kw+gFHxeh9iuvsdGNSHsleAfXnlhwTm3DgvZ/6WbSb+yBKmAv/mvff9iznZ KRnWqU9dZiCPZChBf68ptvK0xcIp+AEeALxqpRtUOwBzT+czwp4kdJ//MjDfkRNOOk22 embIoYUAd6len/MLOBDM43f52D1HS783cMQwJpsUfu/pIEar37MiaYMlfnQ3LRSTpBWa A5JBNEiFi3Y4h7tTPAdZxsSbrdjvVUSPEijjk3ud5aLl8GZUSo2OQBdQAZ7sOUKicJuX ccXLmp4RWeq1fSPEF8HipzAGtBR0rDwCCt5mYi+aEY3ai+QppvVc600dx5a+AVXXEXte XvMw== X-Forwarded-Encrypted: i=1; AL+hErEt1SBhipP2rm963g9xd/qlIcEF52R6p6OOL+9t0l/FLMwXy18DCTPgP3A2Dax0CCeoWrZSrNfBJ43R2RE=@vger.kernel.org X-Gm-Message-State: APuU4Z+pmZenp8pGTenxuKReceOvPaMWq/L9PfuPzai1f2d7hIGPtX2J zk0+m6kR8dY/GXZWRViS+5AQ0/YZcnreOA6I7vkspKzMTq5kNk/SFTWkXwbgdQSH X-Gm-Gg: AZFdTZciFNIHBxnyW0xfosUjKf5zWTEa5/8GPoxML2JbYya1wbWNUyCDH5X7O4E2+Dm upR+mQrwwrB4KmScHze0fUmX/SIZbORy0W+ot0KT895fByjDZl+Axw3Ew2uc+vzHQBNPRJsVcbT uFNyM6nRXs7OkKgGq03hHO66Wu+8vxg/SzoZrdTKtDTvu5fwche1Vw2dJWhP6CA3XlTxIMiBAiP cwCC++ZjSTLr5qpUFv47OHAAogtq9PadHB2w1r8c4gLEaqNUa+mlhnK0TMl1NUe7qgldiO4Peim JVc9xPE3ML7D97eBxcPCy2xjtKLbmildUtoPfozvBsgx+0HI/Lf2+8aM1tOLv7+KV5H8r6rHiZN Jt7QEP6ZgLdkNPngU5z2S4CnecQ1PfUgpSxJRu6UdQB6OLIH4T/5SrxqTvyJxi6ZNxMFbFmZ80I +8uRigxS8vEFFXDrwfW9Fqo3TWbeePuwke9oU3G/u7Cjm4sB2xpD4H9bJgYAU0g7ULwcjjt3d9M uOMaByPQz3FOZaq7PNV9AQmlnnv2PGO4bYS8Yu4BLPH9Fz3K2t8tw43yXdKNLuuJQLQ8fokJ0c/ EEnD8YS6fn4ZZBBF4QHsKzX+YEbarFRIQC6zRc4H2JGm9V2Fb8+6+tEXXdH5yhkPTMlCnTNVTXi xsTYwva2R 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-kernel@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! ~~