From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796368095; b=0lq8ZfzHYrrbP0GIsMDqe2geOq1wbkfBCZCPIveKxU4mgIdT0rVJUuWvRtYaVvglbSH9 xafWNb8Z7l+oXmOXassAqtxVDrqbxLAfvcstYgUi0DDu5+t+iTHZSHbiS7iLA+jYWjVfN 9AS/h727dhssurHsWxWCk6xJnk2UYyUgzhQU++QZzfn5WxIfzOaFYjbFMrr12RJdK9sGo 3nh/6Z6GvwmvN4u9fzB8Z2u+mwWZXCFZKx3mE7B4ISpTQMyPCr6XoqYxAyOzVAtwA1/kx p2w8bruodY/amzqI/G4WJVlxCtvdghLi8KuzeNylrG0S6DC5ht6RimA3m5Dxe+5oTYg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796368095; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=mI5pdfhGoGfRb6/HA1xFpCd2zhWrWaYQvr+ElFQfGoI=; b=Zt0Ohd5v+kdhgYGfe59FiruqwNBBlXuyNmwinf0ADy2V0BNAe588mY+GquCUq7c1vdOe xQ6oAiyhDnrJ23ozJMge4FiwiDeJZf5ihMw8/GGQcnq8KsR5SuVfvcK6KVz2vAasEvuH+ yhXY1M3MibFYaC/goVjfx8A8a8Qpn4SewRUaDGOcQqQ/u/ZUm7Rh+8Q6p7kaKJndmC6yG YUIX61uUXARyyn96SV5SZlAOpUTy8t3W0HQ07FDp1KIXpfyTKT3Xi3lh+5RlBxR5nokN6 vCVus10DogGCNltL11nRaDviyJNblkUkP9m963RtSfAos2ly3CBTwvjlIAdTjzMdw6A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=FfDC4yM9; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4C28F606A32D for ; Fri, 4 Dec 2026 07:08:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=FfDC4yM9 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9BF6F1F000C2; Fri, 4 Dec 2026 07:08:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796368094; bh=mI5pdfhGoGfRb6/HA1xFpCd2zhWrWaYQvr+ElFQfGoI=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=FfDC4yM9OA6tNR23+mAr0KZWcWxA4VytJGI4FilmhC55/fI5PtNbItgoB84TtWIFD K1MO9L4oJhIcfmjrB/Fzia9HQuyIXB0NYhCalpPwhVBiZLJ2uUlUJ7qDptu79t2Vbq Vu4vUhdvW8NPwk5anGzN5MV34qqq5XRLC5gmOWbEvIHiBUDUDS0cq4Rrdh6kM/2gdS gWhvYHYcZAzQ4fM5Cq3ZQ5frb0+PsjOlC/cX8mW/bYOoo/KlPBU2NzBenQW17lbNxQ zf5vKAssN+tcOHZF8w0t6imELOqu07Zsw7ebGb+tCV6Y2GMgJmejuupYXdD33Dy7Ln 38gjr3n77LLTA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v2 2/2] platform/asus: Add driver for ASUS Transformer's Dock of Tegra based devices Reply-To: sashiko-reviews@lists.linux.dev To: "Svyatoslav Ryhel" Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org In-Reply-To: <20261204063414.63617-3-clamor95@gmail.com> References: <20261204063414.63617-1-clamor95@gmail.com> <20261204063414.63617-3-clamor95@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 07:08:14 +0000 X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 7 potential issues to consider: - [High] platform/asus: double-free and UAF reusing priv->adap after failed add - [Medium] platform/asus: asus_tf_dock_probe() returns -ENODEV instead of -EPROBE_DEFER - [Medium] platform/asus: asus_tf_dock_activate() sets wrong adap.dev.parent - [Medium] platform/asus: missing PM resume callback misses dock changes in suspend - [Medium] platform/asus: asus_tf_dock_algo omits xfer_atomic and uses deprecated master_xfer - [Medium] platform/asus: nested I2C retries in asus_tf_dock_probe() - [Low] platform/asus: shared static i2c_bus_recovery_info mutated without locking -- commit a88f182670e0c763b88a8c86992d33cc8ebfaf13 Author: Micha=C5=82 Miros=C5=82aw platform/asus: Add driver for ASUS Transformer's Dock of Tegra based devices This commit adds a platform driver for the ASUS Transformer dock on Tegra-based devices, exposing a hot-pluggable child I2C adapter whose presence is tracked via a detect GPIO. > diff --git a/drivers/platform/asus/asus-transformer-dock.c b/drivers/plat= form/asus/asus-transformer-dock.c > new file mode 100644 > index 0000000000000..a3f5e5ddcb0c7 > --- /dev/null > +++ b/drivers/platform/asus/asus-transformer-dock.c > @@ -0,0 +1,282 @@ [ ... ] > +static const struct i2c_algorithm asus_tf_dock_algo_i2c =3D { > + .master_xfer =3D asus_tf_dock_master_xfer, > + .functionality =3D asus_tf_dock_functionality, > +}; > + > +static const struct i2c_algorithm asus_tf_dock_algo_smbus =3D { > + .smbus_xfer =3D asus_tf_dock_smbus_xfer, > + .functionality =3D asus_tf_dock_functionality, > +}; > + > +static const struct i2c_algorithm asus_tf_dock_algo_both =3D { > + .master_xfer =3D asus_tf_dock_master_xfer, > + .smbus_xfer =3D asus_tf_dock_smbus_xfer, > + .functionality =3D asus_tf_dock_functionality, > +}; [Severity: Medium] Should these i2c_algorithm structs use .xfer instead of the deprecated .master_xfer and propagate .xfer_atomic / .smbus_xfer_atomic from parent? Tegra's tegra_i2c_algo supports .xfer_atomic, so an atomic dock transfer during shutdown or reboot triggers a WARN in __i2c_lock_bus_helper() and breaks atomic SMBus fallback in __i2c_smbus_xfer(). Populating a per-instance struct i2c_algorithm from parent->algo avoids this. [ ... ] > +static struct i2c_bus_recovery_info asus_tf_dock_recovery_info =3D { > + .recover_bus =3D asus_tf_dock_recover_bus, > +}; [Severity: Low] Can sharing a single mutable static struct i2c_bus_recovery_info across instances cause a data race during adapter registration? i2c_add_adapter() -> i2c_register_adapter() -> i2c_init_recovery() calls i2c_gpio_init_pinctrl_recovery() without holding core_lock, mutating bri->pinctrl, bri->pins_default, and bri->pins_gpio before non-generic recover_bus callbacks are skipped. Embedding struct i2c_bus_recovery_info in struct asus_tf_dock_priv eliminates the shared mutable state. > +static int asus_tf_dock_activate(struct asus_tf_dock_priv *priv) > +{ > + int ret; > + > + if (test_bit(ASUS_TF_DOCK_ATTACHED, &priv->state_flags)) > + return 0; > + > + /* > + * Store the dev data in adapter dev, since > + * previous i2c_del_adapter might have wiped it. > + */ > + priv->adap.dev.parent =3D priv->dev; [Severity: Medium] Should priv->adap.dev.parent be &priv->parent->dev rather than priv->dev? i2c_parent_is_i2c_adapter() and i2c_adapter_depth() check for ancestors of type &i2c_adapter_type. Using the platform device breaks cross-bus address collision detection in i2c_check_addr_busy(), stops i2c_root_adapter() at priv->adap, and loses lockdep depth and parent-child async PM ordering. > + device_set_node(&priv->adap.dev, priv->i2c_fwnode); > + > + dev_dbg(priv->adap.dev.parent, "connection detected"); > + > + ret =3D i2c_add_adapter(&priv->adap); > + if (!ret) > + set_bit(ASUS_TF_DOCK_ATTACHED, &priv->state_flags); > + > + return ret; > +} [ ... ] > + if (state) > + asus_tf_dock_activate(priv); > + else > + asus_tf_dock_deactivate(priv); [Severity: High] Can reusing priv->adap after a failed i2c_add_adapter() cause a double free and use-after-free on the next attach interrupt? Unlike i2c_del_adapter(), i2c_register_adapter()'s err_put_adap path calls put_device(&adap->dev) without zeroing adap->dev. If registration fails after device_initialize() (e.g., in device_add()), kobject_cleanup() frees kobj.name and device_release() frees dev->p without clearing them. Since ASUS_TF_DOCK_ATTACHED remains clear and asus_tf_dock_interrupt() ignores the return value, the next attach retries on the released device: dev_set_name() double frees kobj.name and device_add() dereferences the dangling dev->p. Allocating a fresh struct i2c_adapter per activation (or zeroing priv->adap.dev before registration) and logging errors from asus_tf_dock_activate() would avoid this. [ ... ] > + parent =3D of_get_i2c_adapter_by_node(parent_np); > + of_node_put(parent_np); > + if (!parent) > + return dev_err_probe(dev, -ENODEV, > + "Failed to get parent I2C adapter\n"); [Severity: Medium] Should this return -EPROBE_DEFER instead of -ENODEV when parent is NULL? of_get_i2c_adapter_by_node() returns NULL whenever the parent I2C adapter has not registered yet (for instance with modular or asynchronously probed controllers, or fw_devlink=3Doff). Returning -ENODEV permanently aborts probe instead of deferring, leaving the dock bus and its devices unbound. [ ... ] > + priv->adap.retries =3D parent->retries; > + priv->adap.timeout =3D parent->timeout; [Severity: Medium] Does copying parent->retries and parent->timeout nest the I2C core retry loops on -EAGAIN? asus_tf_dock_master_xfer() and asus_tf_dock_smbus_xfer() delegate to __i2c_transfer(parent, ...) and __i2c_smbus_xfer(parent, ...), running the parent retry loop inside priv->adap's loop. On arbitration loss, attempts are squared to (parent->retries + 1)^2 while holding parent->bus_lock. Leaving priv->adap.retries at 0 lets the parent adapter handle retries once without nesting. [ ... ] > +static struct platform_driver asus_tf_dock_driver =3D { > + .driver =3D { > + .name =3D "asus-transformer-dock", > + .of_match_table =3D asus_tf_dock_of_match, > + }, > + .probe =3D asus_tf_dock_probe, > +}; [Severity: Medium] Does this driver miss dock attach and detach events that occur during system suspend? On Tegra, tegra_gpio_suspend() masks non-wakeup GPIO interrupts and tegra_gpio_resume() does not synthesize missed edges. Without enable_irq_wake() or a PM resume callback to re-check priv->gpio, docking or undocking during suspend leaves software state out of sync on resume. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204063414.6361= 7-1-clamor95@gmail.com?part=3D2