From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.167.45 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796192885; b=TmDSRmD9Ou3tC7CwY82dNOuaYNYEC9wC2GtzR/2y7QwosALcdXkgZWboTiemQEKjNQIg uIoDMKgzpC2+A6LGltJMQDUQtYGDMy5Pmm0CZHPdVv7/O3d714Jxn30e9jcg5hwRQRbbn D2CS0PG0H95+xY3bOGowwjSfiGyE8Fy/8UHGp+Pi86wajOQBIe3aYAUa5PZXhK9RgZRXw sLyywCXidk8HK5Zg7BvhK4bgamFXcR4/0RziKbPXQdBv7lTH65nAIIgqwoyeR7nmyuE5O nOw+o/khlnRGHbVBoZg77+b04PyAPQPXm/RSTaJrP6t9dwB4q89froBaJiWGJE5op+A== 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=CLFw20dgWHePt7OJWTQk0vzLU5dqGA96tI9VatQHGAYkvkG+ZAyX+kb9vRHpwL3zmPgS k0F4XquYLOjxRQMaqaGcZ+H23rt5nlO0jztkhECm0JWiGMTQH4e4kDveR/4HepvFnJLOf KTXTyF2NskqnBAew98ai090G/UznzRmG+AF1Pyw0ywmthHACp05W+woTNgFSBYCYfKygo kQeunORf8EdpnEvZgaGGvPgS7XvdGf6Kk75Ry3FzWeD/6mlP1WGBgt+WULUj7KS/YvC7V PjZPKMyghdtU9sDFRbLnPJgnzQxiCKgyBIAEU02EPc6erjeBNOp8TnGqj0y9ypkEjag== 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=BkR1OGNi; arc=none smtp.remote-ip=209.85.167.45 Received: from mail-lf1-f45.google.com (mail-lf1-f45.google.com [209.85.167.45]) (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 687A8606A331 for ; Wed, 2 Dec 2026 06:28:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 687A8606A331 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=BkR1OGNi Received: by mail-lf1-f45.google.com with SMTP id 2adb3069b0e04-5c126f80426so11910330e87.1 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=lists.linux.dev; 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=BkR1OGNi6f3qblJbGxI1BAnAym44J/8rqsj8HZPlwub7Vxo2Y1uI6ltrfqxdtd6zfl TlWFTSNt2SYJHBNHgTyq+wPHHI9RlLY4PzjEucoQmgbdSzWjdyUFEJrD+9I8faSy9KZp d5JalS22ZryPYDGDh0perR/dQrYPR5CQuBJsYjwg7+vDlthc5tfRAKiK+xdXstRQnsdr qcjbJWowoqdDJlp1i/88OjLE/JFL0l4Hbwh7EbG4QX2GlpTeu27nNFeoX1XjBvCXoo59 wDZGfS7/HskeLLuO6auOKkWwps+fEzBWjShXR5rGivMUOLOctUKABfHTGWAb/V2OakTE RwxQ== 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=w8gkZhG3eXMqsX1szgzkytf1Yk8eHdspviv6cZHThNzw5oy2ga08gQAstze2ua4wOY jaMe0Aw1n20E+wkmMv+xOZtXtIqvr+lG7MqTQ0DjxI8+wwy05ojib7E5rvxjN2q8FwBK eqcsbhIJ8qpTegMdjDtg60dFPWaPu0VCa9loFUuyCW6pRTOoXnlRPdCzK6S3zSaU+3oC YwJJeYulkC+lSQ2N0cMYIFLN6cJqu+Xd3JZY50FnKkCfizf40l31PmUPNStnwKU5Vy8v rN7coNw1gNDN1qdDWPjhcFQBln8zvvJV4PiINqLMv+jiH0rQlTqGNZPvnv1UlCddEA15 48uQ== X-Forwarded-Encrypted: i=1; AL+hErEiG2et9VvtwtRKBGOBypDeyLhirBPX9Dr2lsymjpQnJlXXoALFykpjidJypUDpPvDsvkNW@lists.linux.dev X-Gm-Message-State: APuU4Z+wn2MdOMBqOugH0Q7RrI1iA4AcXIVZ+wc9A4TslNM1XyLtFL5I pslKFKE6mw/8nhMBU7cAg+VW9AafX8uqubDNuJYz5MKM9lNtsLtjlz79 X-Gm-Gg: AZFdTZfK1exf4nDkt1WHHgyZOn0o7r2xBnLHXeh3PWgv7RiGW8unY4gXE6cUvq92Hhb OPW+kRlIZkyKcIA4nMiHkJLneBJDlLlYVdL8+zL1AbeB4dRZNnnEPFYmtu/zGQyGeGGm5tT6oIU YT2EbH3uLgcrCK2QCS0a47bgRDwu3CGeru+XGIvCCg+dqNEl5H3ONwx4HPO7Aw7CiququrF4jXK MTMLlSP10B/Sgvin+rEUHD4bPFaKz76O1cSa21Yj/RWepbeIezaXQmZgONdQ7Uh/LfJa2Aa1lcV 7aEfj6BJwLXK/p1gDCy7IulfzBDzKdGlpbL+BfwLUrwuzv0p8huPoUlkNEx8zt4uIHaUBEg/cLD gMQ9Tbsa9/E81jMn7OHhLYrXAyL5nrZDy83NhfdV+gcO49iePv0Jw2AUf17+IQ6GghUJC55mQXR q5n3SmliKaP50MmEJWpe5/fcYAByXZOupe29JBpfu+ZlXoHADbMSXgDjVUkEx8t2S17b6Lv5Iae LyND1agF5Chv76Lray7970BQjjWktuE/C+4JGuYg7nP6eHdCmeQIzPGQPAM9eW6FwI8gMssZ9px 6onV63BXh1+5LBGW395x1+wDIpr/stF9lfrwuDCxvp7alDtvWRzFyM1aJrSARQjCF5PhdseAOZc ZyJmqypHI 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: llvm@lists.linux.dev 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! ~~