Re: [PATCH 2/7] greybus: connection: Add gb_connection_hd_find_by_intf()
flat view
From: sashiko-bot@kernel.org
Date: 2026-08-20 09:32:45
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] Unconditional dereference of `connection->intf` in `gb_connection_hd_find_by_intf` causes a kernel panic when encountering static connections. --
--- Patch [2]: [PATCH 2/7] greybus: connection: Add gb_connection_hd_find_by_intf() ---commit aaa6e0238f2ed224615968bb243b01db7948e7a8
Author: Ayush Singh [off-list ref]
greybus: connection: Add gb_connection_hd_find_by_intf()
This commit introduces a new function to look up a connection on a host
device using its remote interface id and CPort id. The function walks
the host device's connection list and returns a reference-counted pointer
to the matching connection.
quoted hunk ↗ jump to hunk
diff --git a/drivers/greybus/connection.c b/drivers/greybus/connection.c index f8fda22bc4667..262161fa4721c 100644 --- a/drivers/greybus/connection.c +++ b/drivers/greybus/connection.c
[ ... ]
quoted hunk ↗ jump to hunk
+struct gb_connection *gb_connection_hd_find_by_intf(struct gb_host_device *hd, + u8 intf_id, u16 intf_cport) +{ + struct gb_connection *connection; + unsigned long flags; + + spin_lock_irqsave(&gb_connections_lock, flags); + list_for_each_entry(connection, &hd->connections, hd_links) { + if (connection->intf->interface_id == intf_id &&
[Severity: High] Could this cause a NULL pointer dereference for static connections? Static connections, such as the core SVC connection created in gb_svc_add(), are instantiated via gb_connection_create_static() which passes NULL for the intf parameter. This leaves connection->intf as NULL. Since static connections are appended to the hd->connections list, will this loop crash when evaluating connection->intf->interface_id if it encounters a static connection before finding a match?
quoted hunk ↗ jump to hunk
+ connection->intf_cport_id == intf_cport) { + gb_connection_get(connection); + goto found; + } + } + connection = NULL; +found: + spin_unlock_irqrestore(&gb_connections_lock, flags); + + return connection; +}
-- Sashiko AI review · https://sashiko.dev/#/patchset/20260820-gb-uart-transport-v1-0-282da14ab7b7@beagleboard.org?part=2