| 0/0 |
2026/07/31 06:48 |
flow |
patching |
1h05m
Results: map[AckedBy:[] Fixes:map[AuthorEmail:duncan.sands@math.u-psud.fr AuthorName:Duncan Sands Hash:1b0e614652344a2d39eb336f3dc07651782883bf Title:[PATCH] USB ATM: driver for the Conexant AccessRunner chipset cxacru] KernelBranch:master KernelCommit:f5098b6bae761e346ebcd9da7f95622c04733cff KernelRepo:git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git PatchDescription:usb: atm: cxacru: properly kill rcv_urb on error in cxacru_cm()
If cxacru_cm() encounters an error while submitting or waiting for snd_urb,
it aborts and returns the error without killing the already submitted
rcv_urb. This leaves the rcv_urb active.
When this happens during initialization (e.g., in cxacru_atm_start()), the
driver may ignore the error and proceed to call cxacru_poll_status(), which
invokes cxacru_cm() again. Attempting to submit the still-active rcv_urb
triggers a warning in usb_submit_urb():
cxacru 1-1:1.0: send of cm 0x84 failed (-104)
ATM dev 0: cxacru_atm_start: CHIP_ADSL_LINE_START returned -104
------------[ cut here ]------------
URB ffff88812658d200 submitted while active
WARNING: drivers/usb/core/urb.c:379 at usb_submit_urb+0x79/0x18b0
drivers/usb/core/urb.c:379
...
Call Trace:
<TASK>
cxacru_cm+0x21a/0xf10 drivers/usb/atm/cxacru.c:631
cxacru_cm_get_array drivers/usb/atm/cxacru.c:722 [inline]
cxacru_poll_status+0x178/0x1110 drivers/usb/atm/cxacru.c:828
cxacru_atm_start+0x185/0x360 drivers/usb/atm/cxacru.c:814
usbatm_atm_init+0x144/0x3a0 drivers/usb/atm/usbatm.c:927
usbatm_usb_probe+0x15cb/0x1db0 drivers/usb/atm/usbatm.c:1178
cxacru_usb_probe+0x17f/0x220 drivers/usb/atm/cxacru.c:1370
...
To fix this, ensure that rcv_urb is properly killed if cxacru_cm() aborts
early. We can safely call usb_kill_urb() on rcv_urb in the error path, as
it is safe to call even if the URB is not active (e.g., if it failed to
submit in the first place, or if it already completed). PatchDiff:diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
index f1900c567..429ac20a8 100644
--- a/drivers/usb/atm/cxacru.c
+++ b/drivers/usb/atm/cxacru.c
@@ -700,6 +700,8 @@ static int cxacru_cm(struct cxacru_data *instance, enum cxacru_cm_request cm,
ret = offd;
usb_dbg(instance->usbatm, "cm %#x\n", cm);
fail:
+ if (ret < 0)
+ usb_kill_urb(instance->rcv_urb);
mutex_unlock(&instance->cm_serialize);
err:
return ret;
Recipients:[map[Email:3chas3@gmail.com Name:Chas Williams To:true] map[Email:accessrunner-general@lists.sourceforge.net Name: To:true] map[Email:gregkh@linuxfoundation.org Name:Greg Kroah-Hartman To:true] map[Email:linux-atm-general@lists.sourceforge.net Name: To:true] map[Email:linux-kernel@vger.kernel.org Name: To:false] map[Email:linux-usb@vger.kernel.org Name: To:true] map[Email:netdev@vger.kernel.org Name: To:true] map[Email:duncan.sands@math.u-psud.fr Name:Duncan Sands To:true]] ReportedBy:[] ReviewedBy:[] TestedBy:[]]
|
| 1/1 |
2026/07/31 06:48 |
action |
base-commit-picker |
0m
Results: map[KernelBranch:master KernelCommit:f5098b6bae761e346ebcd9da7f95622c04733cff KernelRepo:git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git]
|
| 2/1 |
2026/07/31 06:48 |
action |
syz-repro-to-c-repro |
0m
Results: map[SimplifiedCRepro:// autogenerated by syzkaller (https://github.com/google/syzkaller)
#define _GNU_SOURCE
#include <endian.h>
#include <errno.h>
#include <fcntl.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mount.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <unistd.h>
#include <linux/usb/ch9.h>
static unsigned long long procid;
static void sleep_ms(uint64_t ms)
{
usleep(ms * 1000);
}
#define MAX_FDS 30
#define USB_MAX_IFACE_NUM 4
#define USB_MAX_EP_NUM 32
#define USB_MAX_FDS 6
struct usb_endpoint_index {
struct usb_endpoint_descriptor desc;
int handle;
};
struct usb_iface_index {
struct usb_interface_descriptor* iface;
uint8_t bInterfaceNumber;
uint8_t bAlternateSetting;
uint8_t bInterfaceClass;
struct usb_endpoint_index eps[USB_MAX_EP_NUM];
int eps_num;
};
struct usb_device_index {
struct usb_device_descriptor* dev;
struct usb_config_descriptor* config;
uint8_t bDeviceClass;
uint8_t bMaxPower;
int config_length;
struct usb_iface_index ifaces[USB_MAX_IFACE_NUM];
int ifaces_num;
int iface_cur;
};
struct usb_info {
int fd;
struct usb_device_index index;
};
static struct usb_info usb_devices[USB_MAX_FDS];
static struct usb_device_index* lookup_usb_index(int fd)
{
for (int i = 0; i < USB_MAX_FDS; i++) {
if (__atomic_load_n(&usb_devices[i].fd, __ATOMIC_ACQUIRE) == fd)
return &usb_devices[i].index;
}
return NULL;
}
static int usb_devices_num;
static bool parse_usb_descriptor(const char* buffer, size_t length, struct usb_device_index* index)
{
if (length < sizeof(*index->dev) + sizeof(*index->config))
return false;
memset(index, 0, sizeof(*index));
index->dev = (struct usb_device_descriptor*)buffer;
index->config = (struct usb_config_descriptor*)(buffer + sizeof(*index->dev));
index->bDeviceClass = index->dev->bDeviceClass;
index->bMaxPower = index->config->bMaxPower;
index->config_length = length - sizeof(*index->dev);
index->iface_cur = -1;
size_t offset = 0;
while (true) {
if (offset + 1 >= length)
break;
uint8_t desc_length = buffer[offset];
uint8_t desc_type = buffer[offset + 1];
if (desc_length <= 2)
break;
if (offset + desc_length > length)
break;
if (desc_type == USB_DT_INTERFACE && index->ifaces_num < USB_MAX_IFACE_NUM) {
struct usb_interface_descriptor* iface = (struct usb_interface_descriptor*)(buffer + offset);
index->ifaces[index->ifaces_num].iface = iface;
index->ifaces[index->ifaces_num].bInterfaceNumber = iface->bInterfaceNumber;
index->ifaces[index->ifaces_num].bAlternateSetting = iface->bAlternateSetting;
index->ifaces[index->ifaces_num].bInterfaceClass = iface->bInterfaceClass;
index->ifaces_num++;
}
if (desc_type == USB_DT_ENDPOINT && index->ifaces_num > 0) {
struct usb_iface_index* iface = &index->ifaces[index->ifaces_num - 1];
if (iface->eps_num < USB_MAX_EP_NUM) {
memcpy(&iface->eps[iface->eps_num].desc, buffer + offset, sizeof(iface->eps[iface->eps_num].desc));
iface->eps_num++;
}
}
offset += desc_length;
}
return true;
}
static struct usb_device_index* add_usb_index(int fd, const char* dev, size_t dev_len)
{
int i = __atomic_fetch_add(&usb_devices_num, 1, __ATOMIC_RELAXED);
if (i >= USB_MAX_FDS)
return NULL;
if (!parse_usb_descriptor(dev, dev_len, &usb_devices[i].index))
return NULL;
__atomic_store_n(&usb_devices[i].fd, fd, __ATOMIC_RELEASE);
return &usb_devices[i].index;
}
struct vusb_connect_string_descriptor {
uint32_t len;
char* str;
} __attribute__((packed));
struct vusb_connect_descriptors {
uint32_t qual_len;
char* qual;
uint32_t bos_len;
char* bos;
uint32_t strs_len;
struct vusb_connect_string_descriptor strs[0];
} __attribute__((packed));
static const char default_string[] = {
8, USB_DT_STRING,
's', 0, 'y', 0, 'z', 0
};
static const char default_lang_id[] = {
4, USB_DT_STRING,
0x09, 0x04
};
static bool lookup_connect_response_in(int fd, const struct vusb_connect_descriptors* descs,
const struct usb_ctrlrequest* ctrl,
struct usb_qualifier_descriptor* qual,
char** response_data, uint32_t* response_length)
{
struct usb_device_index* index = lookup_usb_index(fd);
uint8_t str_idx;
if (!index)
return false;
switch (ctrl->bRequestType & USB_TYPE_MASK) {
case USB_TYPE_STANDARD:
switch (ctrl->bRequest) {
case USB_REQ_GET_DESCRIPTOR:
switch (ctrl->wValue >> 8) {
case USB_DT_DEVICE:
*response_data = (char*)index->dev;
*response_length = sizeof(*index->dev);
return true;
case USB_DT_CONFIG:
*response_data = (char*)index->config;
*response_length = index->config_length;
return true;
case USB_DT_STRING:
str_idx = (uint8_t)ctrl->wValue;
if (descs && str_idx < descs->strs_len) {
*response_data = descs->strs[str_idx].str;
*response_length = descs->strs[str_idx].len;
return true;
}
if (str_idx == 0) {
*response_data = (char*)&default_lang_id[0];
*response_length = default_lang_id[0];
return true;
}
*response_data = (char*)&default_string[0];
*response_length = default_string[0];
return true;
case USB_DT_BOS:
*response_data = descs->bos;
*response_length = descs->bos_len;
return true;
case USB_DT_DEVICE_QUALIFIER:
if (!descs->qual) {
qual->bLength = sizeof(*qual);
qual->bDescriptorType = USB_DT_DEVICE_QUALIFIER;
qual->bcdUSB = index->dev->bcdUSB;
qual->bDeviceClass = index->dev->bDeviceClass;
qual->bDeviceSubClass = index->dev->bDeviceSubClass;
qual->bDeviceProtocol = index->dev->bDeviceProtocol;
qual->bMaxPacketSize0 = index->dev->bMaxPacketSize0;
qual->bNumConfigurations = index->dev->bNumConfigurations;
qual->bRESERVED = 0;
*response_data = (char*)qual;
*response_length = sizeof(*qual);
return true;
}
*response_data = descs->qual;
*response_length = descs->qual_len;
return true;
default:
break;
}
break;
default:
break;
}
break;
default:
break;
}
return false;
}
typedef bool (*lookup_connect_out_response_t)(int fd, const struct vusb_connect_descriptors* descs,
const struct usb_ctrlrequest* ctrl, bool* done);
static bool lookup_connect_response_out_generic(int fd, const struct vusb_connect_descriptors* descs,
const struct usb_ctrlrequest* ctrl, bool* done)
{
switch (ctrl->bRequestType & USB_TYPE_MASK) {
case USB_TYPE_STANDARD:
switch (ctrl->bRequest) {
case USB_REQ_SET_CONFIGURATION:
*done = true;
return true;
default:
break;
}
break;
}
return false;
}
struct vusb_descriptor {
uint8_t req_type;
uint8_t desc_type;
uint32_t len;
char data[0];
} __attribute__((packed));
struct vusb_descriptors {
uint32_t len;
struct vusb_descriptor* generic;
struct vusb_descriptor* descs[0];
} __attribute__((packed));
struct vusb_response {
uint8_t type;
uint8_t req;
uint32_t len;
char data[0];
} __attribute__((packed));
struct vusb_responses {
uint32_t len;
struct vusb_response* generic;
struct vusb_response* resps[0];
} __attribute__((packed));
static bool lookup_control_response(const struct vusb_descriptors* descs, const struct vusb_responses* resps,
struct usb_ctrlrequest* ctrl, char** response_data, uint32_t* response_length)
{
int descs_num = 0;
int resps_num = 0;
if (descs)
descs_num = (descs->len - offsetof(struct vusb_descriptors, descs)) / sizeof(descs->descs[0]);
if (resps)
resps_num = (resps->len - offsetof(struct vusb_responses, resps)) / sizeof(resps->resps[0]);
uint8_t req = ctrl->bRequest;
uint8_t req_type = ctrl->bRequestType & USB_TYPE_MASK;
uint8_t desc_type = ctrl->wValue >> 8;
if (req == USB_REQ_GET_DESCRIPTOR) {
int i;
for (i = 0; i < descs_num; i++) {
struct vusb_descriptor* desc = descs->descs[i];
if (!desc)
continue;
if (desc->req_type == req_type && desc->desc_type == desc_type) {
*response_length = desc->len;
if (*response_length != 0)
*response_data = &desc->data[0];
else
*response_data = NULL;
return true;
}
}
if (descs && descs->generic) {
*response_data = &descs->generic->data[0];
*response_length = descs->generic->len;
return true;
}
} else {
int i;
for (i = 0; i < resps_num; i++) {
struct vusb_response* resp = resps->resps[i];
if (!resp)
continue;
if (resp->type == req_type && resp->req == req) {
*response_length = resp->len;
if (*response_length != 0)
*response_data = &resp->data[0];
else
*response_data = NULL;
return true;
}
}
if (resps && resps->generic) {
*response_data = &resps->generic->data[0];
*response_length = resps->generic->len;
return true;
}
}
return false;
}
#define UDC_NAME_LENGTH_MAX 128
struct usb_raw_init {
__u8 driver_name[UDC_NAME_LENGTH_MAX];
__u8 device_name[UDC_NAME_LENGTH_MAX];
__u8 speed;
};
enum usb_raw_event_type {
USB_RAW_EVENT_INVALID = 0,
USB_RAW_EVENT_CONNECT = 1,
USB_RAW_EVENT_CONTROL = 2,
};
struct usb_raw_event {
__u32 type;
__u32 length;
__u8 data[0];
};
struct usb_raw_ep_io {
__u16 ep;
__u16 flags;
__u32 length;
__u8 data[0];
};
#define USB_RAW_EPS_NUM_MAX 30
#define USB_RAW_EP_NAME_MAX 16
#define USB_RAW_EP_ADDR_ANY 0xff
struct usb_raw_ep_caps {
__u32 type_control : 1;
__u32 type_iso : 1;
__u32 type_bulk : 1;
__u32 type_int : 1;
__u32 dir_in : 1;
__u32 dir_out : 1;
};
struct usb_raw_ep_limits {
__u16 maxpacket_limit;
__u16 max_streams;
__u32 reserved;
};
struct usb_raw_ep_info {
__u8 name[USB_RAW_EP_NAME_MAX];
__u32 addr;
struct usb_raw_ep_caps caps;
struct usb_raw_ep_limits limits;
};
struct usb_raw_eps_info {
struct usb_raw_ep_info eps[USB_RAW_EPS_NUM_MAX];
};
#define USB_RAW_IOCTL_INIT _IOW('U', 0, struct usb_raw_init)
#define USB_RAW_IOCTL_RUN _IO('U', 1)
#define USB_RAW_IOCTL_EVENT_FETCH _IOR('U', 2, struct usb_raw_event)
#define USB_RAW_IOCTL_EP0_WRITE _IOW('U', 3, struct usb_raw_ep_io)
#define USB_RAW_IOCTL_EP0_READ _IOWR('U', 4, struct usb_raw_ep_io)
#define USB_RAW_IOCTL_EP_ENABLE _IOW('U', 5, struct usb_endpoint_descriptor)
#define USB_RAW_IOCTL_EP_DISABLE _IOW('U', 6, __u32)
#define USB_RAW_IOCTL_EP_WRITE _IOW('U', 7, struct usb_raw_ep_io)
#define USB_RAW_IOCTL_EP_READ _IOWR('U', 8, struct usb_raw_ep_io)
#define USB_RAW_IOCTL_CONFIGURE _IO('U', 9)
#define USB_RAW_IOCTL_VBUS_DRAW _IOW('U', 10, __u32)
#define USB_RAW_IOCTL_EPS_INFO _IOR('U', 11, struct usb_raw_eps_info)
#define USB_RAW_IOCTL_EP0_STALL _IO('U', 12)
#define USB_RAW_IOCTL_EP_SET_HALT _IOW('U', 13, __u32)
#define USB_RAW_IOCTL_EP_CLEAR_HALT _IOW('U', 14, __u32)
#define USB_RAW_IOCTL_EP_SET_WEDGE _IOW('U', 15, __u32)
static int usb_raw_open()
{
return open("/dev/raw-gadget", O_RDWR);
}
static int usb_raw_init(int fd, uint32_t speed, const char* driver, const char* device)
{
struct usb_raw_init arg;
strncpy((char*)&arg.driver_name[0], driver, sizeof(arg.driver_name));
strncpy((char*)&arg.device_name[0], device, sizeof(arg.device_name));
arg.speed = speed;
return ioctl(fd, USB_RAW_IOCTL_INIT, &arg);
}
static int usb_raw_run(int fd)
{
return ioctl(fd, USB_RAW_IOCTL_RUN, 0);
}
static int usb_raw_ep_write(int fd, struct usb_raw_ep_io* io)
{
return ioctl(fd, USB_RAW_IOCTL_EP_WRITE, io);
}
static int usb_raw_ep_read(int fd, struct usb_raw_ep_io* io)
{
return ioctl(fd, USB_RAW_IOCTL_EP_READ, io);
}
static int usb_raw_configure(int fd)
{
return ioctl(fd, USB_RAW_IOCTL_CONFIGURE, 0);
}
static int usb_raw_vbus_draw(int fd, uint32_t power)
{
return ioctl(fd, USB_RAW_IOCTL_VBUS_DRAW, power);
}
static int usb_raw_ep0_write(int fd, struct usb_raw_ep_io* io)
{
return ioctl(fd, USB_RAW_IOCTL_EP0_WRITE, io);
}
static int usb_raw_ep0_read(int fd, struct usb_raw_ep_io* io)
{
return ioctl(fd, USB_RAW_IOCTL_EP0_READ, io);
}
static int usb_raw_event_fetch(int fd, struct usb_raw_event* event)
{
return ioctl(fd, USB_RAW_IOCTL_EVENT_FETCH, event);
}
static int usb_raw_ep_enable(int fd, struct usb_endpoint_descriptor* desc)
{
return ioctl(fd, USB_RAW_IOCTL_EP_ENABLE, desc);
}
static int usb_raw_ep_disable(int fd, int ep)
{
return ioctl(fd, USB_RAW_IOCTL_EP_DISABLE, ep);
}
static int usb_raw_ep0_stall(int fd)
{
return ioctl(fd, USB_RAW_IOCTL_EP0_STALL, 0);
}
static int lookup_interface(int fd, uint8_t bInterfaceNumber, uint8_t bAlternateSetting)
{
struct usb_device_index* index = lookup_usb_index(fd);
if (!index)
return -1;
for (int i = 0; i < index->ifaces_num; i++) {
if (index->ifaces[i].bInterfaceNumber == bInterfaceNumber &&
index->ifaces[i].bAlternateSetting == bAlternateSetting)
return i;
}
return -1;
}
static int lookup_endpoint(int fd, uint8_t bEndpointAddress)
{
struct usb_device_index* index = lookup_usb_index(fd);
if (!index)
return -1;
if (index->iface_cur < 0)
return -1;
for (int ep = 0; ep < index->ifaces[index->iface_cur].eps_num; ep++)
if (index->ifaces[index->iface_cur].eps[ep].desc.bEndpointAddress == bEndpointAddress)
return index->ifaces[index->iface_cur].eps[ep].handle;
return -1;
}
#define USB_MAX_PACKET_SIZE 4096
struct usb_raw_control_event {
struct usb_raw_event inner;
struct usb_ctrlrequest ctrl;
char data[USB_MAX_PACKET_SIZE];
};
struct usb_raw_ep_io_data {
struct usb_raw_ep_io inner;
char data[USB_MAX_PACKET_SIZE];
};
static void set_interface(int fd, int n)
{
struct usb_device_index* index = lookup_usb_index(fd);
if (!index)
return;
if (index->iface_cur >= 0 && index->iface_cur < index->ifaces_num) {
for (int ep = 0; ep < index->ifaces[index->iface_cur].eps_num; ep++) {
int rv = usb_raw_ep_disable(fd, index->ifaces[index->iface_cur].eps[ep].handle);
if (rv < 0) {
} else {
}
}
}
if (n >= 0 && n < index->ifaces_num) {
for (int ep = 0; ep < index->ifaces[n].eps_num; ep++) {
int rv = usb_raw_ep_enable(fd, &index->ifaces[n].eps[ep].desc);
if (rv < 0) {
} else {
index->ifaces[n].eps[ep].handle = rv;
}
}
index->iface_cur = n;
}
}
static int configure_device(int fd)
{
struct usb_device_index* index = lookup_usb_index(fd);
if (!index)
return -1;
int rv = usb_raw_vbus_draw(fd, index->bMaxPower);
if (rv < 0) {
return rv;
}
rv = usb_raw_configure(fd);
if (rv < 0) {
return rv;
}
set_interface(fd, 0);
return 0;
}
static volatile long syz_usb_connect_impl(uint64_t speed, uint64_t dev_len, const char* dev,
const struct vusb_connect_descriptors* descs,
lookup_connect_out_response_t lookup_connect_response_out)
{
if (!dev) {
return -1;
}
int fd = usb_raw_open();
if (fd < 0) {
return fd;
}
if (fd >= MAX_FDS) {
close(fd);
return -1;
}
struct usb_device_index* index = add_usb_index(fd, dev, dev_len);
if (!index) {
return -1;
}
char device[32];
sprintf(&device[0], "dummy_udc.%llu", procid);
int rv = usb_raw_init(fd, speed, "dummy_udc", &device[0]);
if (rv < 0) {
return rv;
}
rv = usb_raw_run(fd);
if (rv < 0) {
return rv;
}
bool done = false;
while (!done) {
struct usb_raw_control_event event;
event.inner.type = 0;
event.inner.length = sizeof(event.ctrl);
rv = usb_raw_event_fetch(fd, (struct usb_raw_event*)&event);
if (rv < 0) {
return rv;
}
if (event.inner.type != USB_RAW_EVENT_CONTROL)
continue;
char* response_data = NULL;
uint32_t response_length = 0;
struct usb_qualifier_descriptor qual;
if (event.ctrl.bRequestType & USB_DIR_IN) {
if (!lookup_connect_response_in(fd, descs, &event.ctrl, &qual, &response_data, &response_length)) {
usb_raw_ep0_stall(fd);
continue;
}
} else {
if (!lookup_connect_response_out(fd, descs, &event.ctrl, &done)) {
usb_raw_ep0_stall(fd);
continue;
}
response_data = NULL;
response_length = event.ctrl.wLength;
}
if ((event.ctrl.bRequestType & USB_TYPE_MASK) == USB_TYPE_STANDARD &&
event.ctrl.bRequest == USB_REQ_SET_CONFIGURATION) {
rv = configure_device(fd);
if (rv < 0) {
return rv;
}
}
struct usb_raw_ep_io_data response;
response.inner.ep = 0;
response.inner.flags = 0;
if (response_length > sizeof(response.data))
response_length = 0;
if (event.ctrl.wLength < response_length)
response_length = event.ctrl.wLength;
response.inner.length = response_length;
if (response_data)
memcpy(&response.data[0], response_data, response_length);
else
memset(&response.data[0], 0, response_length);
if (event.ctrl.bRequestType & USB_DIR_IN) {
rv = usb_raw_ep0_write(fd, (struct usb_raw_ep_io*)&response);
} else {
rv = usb_raw_ep0_read(fd, (struct usb_raw_ep_io*)&response);
}
if (rv < 0) {
return rv;
}
}
sleep_ms(200);
return fd;
}
static volatile long syz_usb_connect(volatile long a0, volatile long a1, volatile long a2, volatile long a3)
{
uint64_t speed = a0;
uint64_t dev_len = a1;
const char* dev = (const char*)a2;
const struct vusb_connect_descriptors* descs = (const struct vusb_connect_descriptors*)a3;
return syz_usb_connect_impl(speed, dev_len, dev, descs, &lookup_connect_response_out_generic);
}
static volatile long syz_usb_control_io(volatile long a0, volatile long a1, volatile long a2)
{
int fd = a0;
const struct vusb_descriptors* descs = (const struct vusb_descriptors*)a1;
const struct vusb_responses* resps = (const struct vusb_responses*)a2;
struct usb_raw_control_event event;
event.inner.type = 0;
event.inner.length = USB_MAX_PACKET_SIZE;
int rv = usb_raw_event_fetch(fd, (struct usb_raw_event*)&event);
if (rv < 0) {
return rv;
}
if (event.inner.type != USB_RAW_EVENT_CONTROL) {
return -1;
}
char* response_data = NULL;
uint32_t response_length = 0;
if ((event.ctrl.bRequestType & USB_DIR_IN) && event.ctrl.wLength) {
if (!lookup_control_response(descs, resps, &event.ctrl, &response_data, &response_length)) {
usb_raw_ep0_stall(fd);
return -1;
}
} else {
if ((event.ctrl.bRequestType & USB_TYPE_MASK) == USB_TYPE_STANDARD ||
event.ctrl.bRequest == USB_REQ_SET_INTERFACE) {
int iface_num = event.ctrl.wIndex;
int alt_set = event.ctrl.wValue;
int iface_index = lookup_interface(fd, iface_num, alt_set);
if (iface_index < 0) {
} else {
set_interface(fd, iface_index);
}
}
response_length = event.ctrl.wLength;
}
struct usb_raw_ep_io_data response;
response.inner.ep = 0;
response.inner.flags = 0;
if (response_length > sizeof(response.data))
response_length = 0;
if (event.ctrl.wLength < response_length)
response_length = event.ctrl.wLength;
if ((event.ctrl.bRequestType & USB_DIR_IN) && !event.ctrl.wLength) {
response_length = USB_MAX_PACKET_SIZE;
}
response.inner.length = response_length;
if (response_data)
memcpy(&response.data[0], response_data, response_length);
else
memset(&response.data[0], 0, response_length);
if ((event.ctrl.bRequestType & USB_DIR_IN) && event.ctrl.wLength) {
rv = usb_raw_ep0_write(fd, (struct usb_raw_ep_io*)&response);
} else {
rv = usb_raw_ep0_read(fd, (struct usb_raw_ep_io*)&response);
}
if (rv < 0) {
return rv;
}
sleep_ms(200);
return 0;
}
static volatile long syz_usb_ep_write(volatile long a0, volatile long a1, volatile long a2, volatile long a3)
{
int fd = a0;
uint8_t ep = a1;
uint32_t len = a2;
char* data = (char*)a3;
int ep_handle = lookup_endpoint(fd, ep);
if (ep_handle < 0) {
return -1;
}
struct usb_raw_ep_io_data io_data;
io_data.inner.ep = ep_handle;
io_data.inner.flags = 0;
if (len > sizeof(io_data.data))
len = sizeof(io_data.data);
io_data.inner.length = len;
memcpy(&io_data.data[0], data, len);
int rv = usb_raw_ep_write(fd, (struct usb_raw_ep_io*)&io_data);
if (rv < 0) {
return rv;
}
sleep_ms(200);
return 0;
}
static volatile long syz_usb_ep_read(volatile long a0, volatile long a1, volatile long a2, volatile long a3)
{
int fd = a0;
uint8_t ep = a1;
uint32_t len = a2;
char* data = (char*)a3;
int ep_handle = lookup_endpoint(fd, ep);
if (ep_handle < 0) {
return -1;
}
struct usb_raw_ep_io_data io_data;
io_data.inner.ep = ep_handle;
io_data.inner.flags = 0;
if (len > sizeof(io_data.data))
len = sizeof(io_data.data);
io_data.inner.length = len;
int rv = usb_raw_ep_read(fd, (struct usb_raw_ep_io*)&io_data);
if (rv < 0) {
return rv;
}
memcpy(&data[0], &io_data.data[0], io_data.inner.length);
sleep_ms(200);
return 0;
}
static long syz_open_dev(volatile long a0, volatile long a1, volatile long a2)
{
if (a0 == 0xc || a0 == 0xb) {
char buf[128];
sprintf(buf, "/dev/%s/%d:%d", a0 == 0xc ? "char" : "block", (uint8_t)a1, (uint8_t)a2);
return open(buf, O_RDWR, 0);
} else {
unsigned long nb = a1;
char buf[1024];
char* hash;
strncpy(buf, (char*)a0, sizeof(buf) - 1);
buf[sizeof(buf) - 1] = 0;
while ((hash = strchr(buf, '#'))) {
*hash = '0' + (char)(nb % 10);
nb /= 10;
}
return open(buf, a2 & ~O_CREAT, 0);
}
}
uint64_t r[2] = {0xffffffffffffffff, 0xffffffffffffffff};
int main(void)
{
syscall(__NR_mmap, /*addr=*/0x1ffffffff000ul, /*len=*/0x1000, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul);
syscall(__NR_mmap, /*addr=*/0x200000000000ul, /*len=*/0x1000000, /*prot=PROT_WRITE|PROT_READ|PROT_EXEC*/7ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul);
syscall(__NR_mmap, /*addr=*/0x200001000000ul, /*len=*/0x1000, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul);
const char* reason;
(void)reason;
intptr_t res = 0;
if (write(1, "executing program\n", sizeof("executing program\n") - 1)) {}
// syz_usb_connect arguments: [
// speed: usb_device_speed = 0x3 (8 bytes)
// dev_len: len = 0x40 (8 bytes)
// dev: ptr[inout, array[ANYUNION]] {
// array[ANYUNION] {
// union ANYUNION {
// ANYBLOB: buffer: {12 01 00 02 00 00 00 40 72 05 fe ca 00 01 00 00 00 01 09 02 2e 00 01 01 00 80 fa 09 04 00 00 04 ff 00 00 00 07 05 01 02 00 02 00 07 05 81 02 00 02 00 07 05 02 02 00 02 00 07 05 82 02 00 02} (length 0x3f)
// }
// }
// }
// conn_descs: nil
// ]
// returns fd_usb
memcpy((void*)0x200000000000, "... [truncated large byte array] ...", 63);
res = -1;
res = syz_usb_connect(/*speed=USB_SPEED_HIGH*/3, /*dev_len=*/0x40, /*dev=*/0x200000000000, /*conn_descs=*/0);
if (res != -1)
r[0] = res;
// syz_usb_ep_read arguments: [
// fd: fd_usb (resource)
// ep: int8 = 0x1 (1 bytes)
// len: len = 0x0 (8 bytes)
// data: nil
// ]
syz_usb_ep_read(/*fd=*/r[0], /*ep=*/1, /*len=*/0, /*data=*/0);
// syz_usb_ep_write arguments: [
// fd: fd_usb (resource)
// ep: int8 = 0x81 (1 bytes)
// len: len = 0x40 (8 bytes)
// data: ptr[in, buffer] {
// buffer: {90 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00} (length 0x40)
// }
// ]
memcpy((void*)0x200000000100, "... [truncated large byte array] ...", 64);
syz_usb_ep_write(/*fd=*/r[0], /*ep=*/0x81, /*len=*/0x40, /*data=*/0x200000000100);
// syz_usb_ep_write arguments: [
// fd: fd_usb (resource)
// ep: int8 = 0x81 (1 bytes)
// len: len = 0x40 (8 bytes)
// data: ptr[in, buffer] {
// buffer: {91 01 00 00 00 11 22 33 44 55 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00} (length 0x40)
// }
// ]
memcpy((void*)0x200000000300, "... [truncated large byte array] ...", 64);
syz_usb_ep_write(/*fd=*/r[0], /*ep=*/0x81, /*len=*/0x40, /*data=*/0x200000000300);
// syz_usb_ep_read arguments: [
// fd: fd_usb (resource)
// ep: int8 = 0x1 (1 bytes)
// len: len = 0x0 (8 bytes)
// data: nil
// ]
syz_usb_ep_read(/*fd=*/r[0], /*ep=*/1, /*len=*/0, /*data=*/0);
// syz_open_dev$evdev arguments: [
// dev: ptr[in, buffer] {
// buffer: {2f 64 65 76 2f 69 6e 70 75 74 2f 65 76 65 6e 74 23 00} (length 0x12)
// }
// id: intptr = 0x2 (8 bytes)
// flags: open_flags = 0x0 (8 bytes)
// ]
// returns fd_evdev
memcpy((void*)0x200000000040, "/dev/input/event#\000", 18);
res = -1;
res = syz_open_dev(/*dev=*/0x200000000040, /*id=*/2, /*flags=*/0);
if (res != -1)
r[1] = res;
// ioctl$EVIOCGMASK arguments: [
// fd: fd_evdev (resource)
// cmd: const = 0x80104592 (4 bytes)
// arg: ptr[in, input_mask] {
// input_mask {
// type: input_codes = 0x0 (4 bytes)
// size: bytesize = 0xffffffffffffff36 (4 bytes)
// ptr: ptr[in, buffer] {
// buffer: {95 2b b3 e0 06 ae 9a 4c 3a} (length 0x9)
// }
// }
// }
// ]
*(uint32_t*)0x200000000300 = 0;
*(uint32_t*)0x200000000304 = 0xffffff36;
*(uint64_t*)0x200000000308 = 0x200000000200;
memcpy((void*)0x200000000200, "\x95\x2b\xb3\xe0\x06\xae\x9a\x4c\x3a", 9);
syscall(__NR_ioctl, /*fd=*/r[1], /*cmd=*/0x80104592, /*arg=*/0x200000000300ul);
// syz_usb_control_io$hid arguments: [
// fd: fd_usb_hid (resource)
// descs: nil
// resps: nil
// ]
syz_usb_control_io(/*fd=*/r[0], /*descs=*/0, /*resps=*/0);
return 0;
}
]
|
| 3/1 |
2026/07/31 06:48 |
action |
kernel-checkouter |
0m
Results: map[KernelSrc:/app/workdir/cache/src/3735123449433f9e6f9fb5b55ddd9994cbcf15f0]
|
| 4/1 |
2026/07/31 06:48 |
action |
kernel-builder |
8m
Results: map[KernelObj:/app/workdir/cache/build/80e967fc890f01cc63398329da51c2cf96e68fa0]
|
| 5/1 |
2026/07/31 06:57 |
action |
crash-reproducer |
7m
Results: map[OtherCrashReports:<nil> ReproducedBugTitle:WARNING in cxacru_cm/usb_submit_urb ReproducedCrashReport:cxacru 1-1:1.0: send of cm 0x84 failed (-104)
ATM dev 0: cxacru_atm_start: CHIP_ADSL_LINE_START returned -104
------------[ cut here ]------------
URB ffff88812658d200 submitted while active
WARNING: drivers/usb/core/urb.c:379 at usb_submit_urb+0x79/0x18b0 drivers/usb/core/urb.c:379, CPU#1: kworker/1:1/5258
Modules linked in:
CPU: 1 UID: 0 PID: 5258 Comm: kworker/1:1 Not tainted syzkaller #1 PREEMPT(lazy)
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
Workqueue: usb_hub_wq hub_event
RIP: 0010:usb_submit_urb+0x7c/0x18b0 drivers/usb/core/urb.c:379
Code: 4c 89 f0 48 c1 e8 03 80 3c 28 00 74 08 4c 89 f7 e8 c9 ab f6 fc 49 83 3e 00 74 40 e8 9e 5e 91 fc 48 8d 3d 47 b1 aa 05 48 89 de <67> 48 0f b9 3a b8 f0 ff ff ff eb 11 e8 83 5e 91 fc eb 05 e8 7c 5e
RSP: 0018:ffffc90002476878 EFLAGS: 00010293
RAX: ffffffff84f3e532 RBX: ffff88812658d200 RCX: ffff88812fb42440
RDX: 0000000000000000 RSI: ffff88812658d200 RDI: ffffffff8a9e9680
RBP: dffffc0000000000 R08: 0000000000000002 R09: 0000000000000000
R10: dffffc0000000000 R11: fffffbfff152f477 R12: 0000000000000040
R13: 0000000000000000 R14: ffff88812658d208 R15: 0000000000000cc0
FS: 0000000000000000(0000) GS:ffff8882a9042000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f7be0a0cfe0 CR3: 000000011d54e000 CR4: 0000000000350ef0
Call Trace:
<TASK>
cxacru_cm+0x21a/0xf10 drivers/usb/atm/cxacru.c:631
cxacru_cm_get_array drivers/usb/atm/cxacru.c:722 [inline]
cxacru_poll_status+0x178/0x1110 drivers/usb/atm/cxacru.c:828
cxacru_atm_start+0x185/0x360 drivers/usb/atm/cxacru.c:814
usbatm_atm_init+0x144/0x3a0 drivers/usb/atm/usbatm.c:927
usbatm_usb_probe+0x15cb/0x1db0 drivers/usb/atm/usbatm.c:1178
cxacru_usb_probe+0x17f/0x220 drivers/usb/atm/cxacru.c:1370
usb_probe_interface+0x653/0xc60 drivers/usb/core/driver.c:396
call_driver_probe drivers/base/dd.c:-1 [inline]
really_probe+0x254/0xae0 drivers/base/dd.c:706
__driver_probe_device+0x1e8/0x360 drivers/base/dd.c:868
driver_probe_device+0x4f/0x240 drivers/base/dd.c:898
__device_attach_driver+0x270/0x410 drivers/base/dd.c:1026
bus_for_each_drv+0x258/0x2f0 drivers/base/bus.c:500
__device_attach+0x2c4/0x450 drivers/base/dd.c:1098
device_initial_probe+0xa1/0xd0 drivers/base/dd.c:1153
bus_probe_device+0x12a/0x220 drivers/base/bus.c:620
device_add+0x7d7/0xb80 drivers/base/core.c:3772
usb_set_configuration+0x1ad8/0x2180 drivers/usb/core/message.c:2268
usb_generic_driver_probe+0x8d/0x150 drivers/usb/core/generic.c:250
usb_probe_device+0x1c3/0x3b0 drivers/usb/core/driver.c:291
call_driver_probe drivers/base/dd.c:-1 [inline]
really_probe+0x254/0xae0 drivers/base/dd.c:706
__driver_probe_device+0x1e8/0x360 drivers/base/dd.c:868
driver_probe_device+0x4f/0x240 drivers/base/dd.c:898
__device_attach_driver+0x270/0x410 drivers/base/dd.c:1026
bus_for_each_drv+0x258/0x2f0 drivers/base/bus.c:500
__device_attach+0x2c4/0x450 drivers/base/dd.c:1098
device_initial_probe+0xa1/0xd0 drivers/base/dd.c:1153
bus_probe_device+0x12a/0x220 drivers/base/bus.c:620
device_add+0x7d7/0xb80 drivers/base/core.c:3772
usb_new_device+0x99d/0x1620 drivers/usb/core/hub.c:2695
hub_port_connect drivers/usb/core/hub.c:5567 [inline]
hub_port_connect_change drivers/usb/core/hub.c:5707 [inline]
port_event drivers/usb/core/hub.c:5871 [inline]
hub_event+0x28e8/0x4d30 drivers/usb/core/hub.c:5953
process_one_work kernel/workqueue.c:3322 [inline]
process_scheduled_works+0xa8e/0x14e0 kernel/workqueue.c:3405
worker_thread+0x92d/0xe10 kernel/workqueue.c:3486
kthread+0x388/0x470 kernel/kthread.c:436
ret_from_fork+0x491/0xad0 arch/x86/kernel/process.c:158
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
</TASK>
----------------
Code disassembly (best guess):
0: 4c 89 f0 mov %r14,%rax
3: 48 c1 e8 03 shr $0x3,%rax
7: 80 3c 28 00 cmpb $0x0,(%rax,%rbp,1)
b: 74 08 je 0x15
d: 4c 89 f7 mov %r14,%rdi
10: e8 c9 ab f6 fc call 0xfcf6abde
15: 49 83 3e 00 cmpq $0x0,(%r14)
19: 74 40 je 0x5b
1b: e8 9e 5e 91 fc call 0xfc915ebe
20: 48 8d 3d 47 b1 aa 05 lea 0x5aab147(%rip),%rdi # 0x5aab16e
27: 48 89 de mov %rbx,%rsi
* 2a: 67 48 0f b9 3a ud1 (%edx),%rdi <-- trapping instruction
2f: b8 f0 ff ff ff mov $0xfffffff0,%eax
34: eb 11 jmp 0x47
36: e8 83 5e 91 fc call 0xfc915ebe
3b: eb 05 jmp 0x42
3d: e8 .byte 0xe8
3e: 7c 5e jl 0x9e
ReproducedFaultInjection:]
|
| 6/1 |
2026/07/31 07:04 |
action |
codesearch-prepare |
11m
Results: map[Index:codesearch-index]
|
| 7/1 |
2026/07/31 07:15 |
agent |
debugger |
7m
Model:
Instruction:
You are an experienced Linux kernel developer tasked with debugging a kernel crash root cause.
You need to provide a detailed explanation of the root cause for another developer to be
able to write a fix for the bug based on your explanation. Include all relevant details
into the response: function/struct/field/etc names, code snippets, line numbers,
macro/enum values, etc.
Don't make assumptions about the kernel source code (it may be different from what you assume it is).
Extensively use the provided code access tools (codesearch-*, git-*, grepper, etc)
to examine the actual source code, and confirm any assumptions.
Prefer calling several tools at the same time to save round-trips.
Prompt:
The crash is:
cxacru 1-1:1.0: send of cm 0x84 failed (-104)
ATM dev 0: cxacru_atm_start: CHIP_ADSL_LINE_START returned -104
------------[ cut here ]------------
URB ffff88812658d200 submitted while active
WARNING: drivers/usb/core/urb.c:379 at usb_submit_urb+0x79/0x18b0 drivers/usb/core/urb.c:379, CPU#1: kworker/1:1/5258
Modules linked in:
CPU: 1 UID: 0 PID: 5258 Comm: kworker/1:1 Not tainted syzkaller #1 PREEMPT(lazy)
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
Workqueue: usb_hub_wq hub_event
RIP: 0010:usb_submit_urb+0x7c/0x18b0 drivers/usb/core/urb.c:379
Code: 4c 89 f0 48 c1 e8 03 80 3c 28 00 74 08 4c 89 f7 e8 c9 ab f6 fc 49 83 3e 00 74 40 e8 9e 5e 91 fc 48 8d 3d 47 b1 aa 05 48 89 de <67> 48 0f b9 3a b8 f0 ff ff ff eb 11 e8 83 5e 91 fc eb 05 e8 7c 5e
RSP: 0018:ffffc90002476878 EFLAGS: 00010293
RAX: ffffffff84f3e532 RBX: ffff88812658d200 RCX: ffff88812fb42440
RDX: 0000000000000000 RSI: ffff88812658d200 RDI: ffffffff8a9e9680
RBP: dffffc0000000000 R08: 0000000000000002 R09: 0000000000000000
R10: dffffc0000000000 R11: fffffbfff152f477 R12: 0000000000000040
R13: 0000000000000000 R14: ffff88812658d208 R15: 0000000000000cc0
FS: 0000000000000000(0000) GS:ffff8882a9042000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f7be0a0cfe0 CR3: 000000011d54e000 CR4: 0000000000350ef0
Call Trace:
<TASK>
cxacru_cm+0x21a/0xf10 drivers/usb/atm/cxacru.c:631
cxacru_cm_get_array drivers/usb/atm/cxacru.c:722 [inline]
cxacru_poll_status+0x178/0x1110 drivers/usb/atm/cxacru.c:828
cxacru_atm_start+0x185/0x360 drivers/usb/atm/cxacru.c:814
usbatm_atm_init+0x144/0x3a0 drivers/usb/atm/usbatm.c:927
usbatm_usb_probe+0x15cb/0x1db0 drivers/usb/atm/usbatm.c:1178
cxacru_usb_probe+0x17f/0x220 drivers/usb/atm/cxacru.c:1370
usb_probe_interface+0x653/0xc60 drivers/usb/core/driver.c:396
call_driver_probe drivers/base/dd.c:-1 [inline]
really_probe+0x254/0xae0 drivers/base/dd.c:706
__driver_probe_device+0x1e8/0x360 drivers/base/dd.c:868
driver_probe_device+0x4f/0x240 drivers/base/dd.c:898
__device_attach_driver+0x270/0x410 drivers/base/dd.c:1026
bus_for_each_drv+0x258/0x2f0 drivers/base/bus.c:500
__device_attach+0x2c4/0x450 drivers/base/dd.c:1098
device_initial_probe+0xa1/0xd0 drivers/base/dd.c:1153
bus_probe_device+0x12a/0x220 drivers/base/bus.c:620
device_add+0x7d7/0xb80 drivers/base/core.c:3772
usb_set_configuration+0x1ad8/0x2180 drivers/usb/core/message.c:2268
usb_generic_driver_probe+0x8d/0x150 drivers/usb/core/generic.c:250
usb_probe_device+0x1c3/0x3b0 drivers/usb/core/driver.c:291
call_driver_probe drivers/base/dd.c:-1 [inline]
really_probe+0x254/0xae0 drivers/base/dd.c:706
__driver_probe_device+0x1e8/0x360 drivers/base/dd.c:868
driver_probe_device+0x4f/0x240 drivers/base/dd.c:898
__device_attach_driver+0x270/0x410 drivers/base/dd.c:1026
bus_for_each_drv+0x258/0x2f0 drivers/base/bus.c:500
__device_attach+0x2c4/0x450 drivers/base/dd.c:1098
device_initial_probe+0xa1/0xd0 drivers/base/dd.c:1153
bus_probe_device+0x12a/0x220 drivers/base/bus.c:620
device_add+0x7d7/0xb80 drivers/base/core.c:3772
usb_new_device+0x99d/0x1620 drivers/usb/core/hub.c:2695
hub_port_connect drivers/usb/core/hub.c:5567 [inline]
hub_port_connect_change drivers/usb/core/hub.c:5707 [inline]
port_event drivers/usb/core/hub.c:5871 [inline]
hub_event+0x28e8/0x4d30 drivers/usb/core/hub.c:5953
process_one_work kernel/workqueue.c:3322 [inline]
process_scheduled_works+0xa8e/0x14e0 kernel/workqueue.c:3405
worker_thread+0x92d/0xe10 kernel/workqueue.c:3486
kthread+0x388/0x470 kernel/kthread.c:436
ret_from_fork+0x491/0xad0 arch/x86/kernel/process.c:158
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
</TASK>
----------------
Code disassembly (best guess):
0: 4c 89 f0 mov %r14,%rax
3: 48 c1 e8 03 shr $0x3,%rax
7: 80 3c 28 00 cmpb $0x0,(%rax,%rbp,1)
b: 74 08 je 0x15
d: 4c 89 f7 mov %r14,%rdi
10: e8 c9 ab f6 fc call 0xfcf6abde
15: 49 83 3e 00 cmpq $0x0,(%r14)
19: 74 40 je 0x5b
1b: e8 9e 5e 91 fc call 0xfc915ebe
20: 48 8d 3d 47 b1 aa 05 lea 0x5aab147(%rip),%rdi # 0x5aab16e
27: 48 89 de mov %rbx,%rsi
* 2a: 67 48 0f b9 3a ud1 (%edx),%rdi <-- trapping instruction
2f: b8 f0 ff ff ff mov $0xfffffff0,%eax
34: eb 11 jmp 0x47
36: e8 83 5e 91 fc call 0xfc915ebe
3b: eb 05 jmp 0x42
3d: e8 .byte 0xe8
3e: 7c 5e jl 0x9e
The following C code is a draft of the vulnerable syscall sequence. Keep in mind that
it may lack the precise threading, sandboxing, and some arguments of a working reproducer:
// autogenerated by syzkaller (https://github.com/google/syzkaller)
#define _GNU_SOURCE
#include <endian.h>
#include <errno.h>
#include <fcntl.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mount.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <unistd.h>
#include <linux/usb/ch9.h>
static unsigned long long procid;
static void sleep_ms(uint64_t ms)
{
usleep(ms * 1000);
}
#define MAX_FDS 30
#define USB_MAX_IFACE_NUM 4
#define USB_MAX_EP_NUM 32
#define USB_MAX_FDS 6
struct usb_endpoint_index {
struct usb_endpoint_descriptor desc;
int handle;
};
struct usb_iface_index {
struct usb_interface_descriptor* iface;
uint8_t bInterfaceNumber;
uint8_t bAlternateSetting;
uint8_t bInterfaceClass;
struct usb_endpoint_index eps[USB_MAX_EP_NUM];
int eps_num;
};
struct usb_device_index {
struct usb_device_descriptor* dev;
struct usb_config_descriptor* config;
uint8_t bDeviceClass;
uint8_t bMaxPower;
int config_length;
struct usb_iface_index ifaces[USB_MAX_IFACE_NUM];
int ifaces_num;
int iface_cur;
};
struct usb_info {
int fd;
struct usb_device_index index;
};
static struct usb_info usb_devices[USB_MAX_FDS];
static struct usb_device_index* lookup_usb_index(int fd)
{
for (int i = 0; i < USB_MAX_FDS; i++) {
if (__atomic_load_n(&usb_devices[i].fd, __ATOMIC_ACQUIRE) == fd)
return &usb_devices[i].index;
}
return NULL;
}
static int usb_devices_num;
static bool parse_usb_descriptor(const char* buffer, size_t length, struct usb_device_index* index)
{
if (length < sizeof(*index->dev) + sizeof(*index->config))
return false;
memset(index, 0, sizeof(*index));
index->dev = (struct usb_device_descriptor*)buffer;
index->config = (struct usb_config_descriptor*)(buffer + sizeof(*index->dev));
index->bDeviceClass = index->dev->bDeviceClass;
index->bMaxPower = index->config->bMaxPower;
index->config_length = length - sizeof(*index->dev);
index->iface_cur = -1;
size_t offset = 0;
while (true) {
if (offset + 1 >= length)
break;
uint8_t desc_length = buffer[offset];
uint8_t desc_type = buffer[offset + 1];
if (desc_length <= 2)
break;
if (offset + desc_length > length)
break;
if (desc_type == USB_DT_INTERFACE && index->ifaces_num < USB_MAX_IFACE_NUM) {
struct usb_interface_descriptor* iface = (struct usb_interface_descriptor*)(buffer + offset);
index->ifaces[index->ifaces_num].iface = iface;
index->ifaces[index->ifaces_num].bInterfaceNumber = iface->bInterfaceNumber;
index->ifaces[index->ifaces_num].bAlternateSetting = iface->bAlternateSetting;
index->ifaces[index->ifaces_num].bInterfaceClass = iface->bInterfaceClass;
index->ifaces_num++;
}
if (desc_type == USB_DT_ENDPOINT && index->ifaces_num > 0) {
struct usb_iface_index* iface = &index->ifaces[index->ifaces_num - 1];
if (iface->eps_num < USB_MAX_EP_NUM) {
memcpy(&iface->eps[iface->eps_num].desc, buffer + offset, sizeof(iface->eps[iface->eps_num].desc));
iface->eps_num++;
}
}
offset += desc_length;
}
return true;
}
static struct usb_device_index* add_usb_index(int fd, const char* dev, size_t dev_len)
{
int i = __atomic_fetch_add(&usb_devices_num, 1, __ATOMIC_RELAXED);
if (i >= USB_MAX_FDS)
return NULL;
if (!parse_usb_descriptor(dev, dev_len, &usb_devices[i].index))
return NULL;
__atomic_store_n(&usb_devices[i].fd, fd, __ATOMIC_RELEASE);
return &usb_devices[i].index;
}
struct vusb_connect_string_descriptor {
uint32_t len;
char* str;
} __attribute__((packed));
struct vusb_connect_descriptors {
uint32_t qual_len;
char* qual;
uint32_t bos_len;
char* bos;
uint32_t strs_len;
struct vusb_connect_string_descriptor strs[0];
} __attribute__((packed));
static const char default_string[] = {
8, USB_DT_STRING,
's', 0, 'y', 0, 'z', 0
};
static const char default_lang_id[] = {
4, USB_DT_STRING,
0x09, 0x04
};
static bool lookup_connect_response_in(int fd, const struct vusb_connect_descriptors* descs,
const struct usb_ctrlrequest* ctrl,
struct usb_qualifier_descriptor* qual,
char** response_data, uint32_t* response_length)
{
struct usb_device_index* index = lookup_usb_index(fd);
uint8_t str_idx;
if (!index)
return false;
switch (ctrl->bRequestType & USB_TYPE_MASK) {
case USB_TYPE_STANDARD:
switch (ctrl->bRequest) {
case USB_REQ_GET_DESCRIPTOR:
switch (ctrl->wValue >> 8) {
case USB_DT_DEVICE:
*response_data = (char*)index->dev;
*response_length = sizeof(*index->dev);
return true;
case USB_DT_CONFIG:
*response_data = (char*)index->config;
*response_length = index->config_length;
return true;
case USB_DT_STRING:
str_idx = (uint8_t)ctrl->wValue;
if (descs && str_idx < descs->strs_len) {
*response_data = descs->strs[str_idx].str;
*response_length = descs->strs[str_idx].len;
return true;
}
if (str_idx == 0) {
*response_data = (char*)&default_lang_id[0];
*response_length = default_lang_id[0];
return true;
}
*response_data = (char*)&default_string[0];
*response_length = default_string[0];
return true;
case USB_DT_BOS:
*response_data = descs->bos;
*response_length = descs->bos_len;
return true;
case USB_DT_DEVICE_QUALIFIER:
if (!descs->qual) {
qual->bLength = sizeof(*qual);
qual->bDescriptorType = USB_DT_DEVICE_QUALIFIER;
qual->bcdUSB = index->dev->bcdUSB;
qual->bDeviceClass = index->dev->bDeviceClass;
qual->bDeviceSubClass = index->dev->bDeviceSubClass;
qual->bDeviceProtocol = index->dev->bDeviceProtocol;
qual->bMaxPacketSize0 = index->dev->bMaxPacketSize0;
qual->bNumConfigurations = index->dev->bNumConfigurations;
qual->bRESERVED = 0;
*response_data = (char*)qual;
*response_length = sizeof(*qual);
return true;
}
*response_data = descs->qual;
*response_length = descs->qual_len;
return true;
default:
break;
}
break;
default:
break;
}
break;
default:
break;
}
return false;
}
typedef bool (*lookup_connect_out_response_t)(int fd, const struct vusb_connect_descriptors* descs,
const struct usb_ctrlrequest* ctrl, bool* done);
static bool lookup_connect_response_out_generic(int fd, const struct vusb_connect_descriptors* descs,
const struct usb_ctrlrequest* ctrl, bool* done)
{
switch (ctrl->bRequestType & USB_TYPE_MASK) {
case USB_TYPE_STANDARD:
switch (ctrl->bRequest) {
case USB_REQ_SET_CONFIGURATION:
*done = true;
return true;
default:
break;
}
break;
}
return false;
}
struct vusb_descriptor {
uint8_t req_type;
uint8_t desc_type;
uint32_t len;
char data[0];
} __attribute__((packed));
struct vusb_descriptors {
uint32_t len;
struct vusb_descriptor* generic;
struct vusb_descriptor* descs[0];
} __attribute__((packed));
struct vusb_response {
uint8_t type;
uint8_t req;
uint32_t len;
char data[0];
} __attribute__((packed));
struct vusb_responses {
uint32_t len;
struct vusb_response* generic;
struct vusb_response* resps[0];
} __attribute__((packed));
static bool lookup_control_response(const struct vusb_descriptors* descs, const struct vusb_responses* resps,
struct usb_ctrlrequest* ctrl, char** response_data, uint32_t* response_length)
{
int descs_num = 0;
int resps_num = 0;
if (descs)
descs_num = (descs->len - offsetof(struct vusb_descriptors, descs)) / sizeof(descs->descs[0]);
if (resps)
resps_num = (resps->len - offsetof(struct vusb_responses, resps)) / sizeof(resps->resps[0]);
uint8_t req = ctrl->bRequest;
uint8_t req_type = ctrl->bRequestType & USB_TYPE_MASK;
uint8_t desc_type = ctrl->wValue >> 8;
if (req == USB_REQ_GET_DESCRIPTOR) {
int i;
for (i = 0; i < descs_num; i++) {
struct vusb_descriptor* desc = descs->descs[i];
if (!desc)
continue;
if (desc->req_type == req_type && desc->desc_type == desc_type) {
*response_length = desc->len;
if (*response_length != 0)
*response_data = &desc->data[0];
else
*response_data = NULL;
return true;
}
}
if (descs && descs->generic) {
*response_data = &descs->generic->data[0];
*response_length = descs->generic->len;
return true;
}
} else {
int i;
for (i = 0; i < resps_num; i++) {
struct vusb_response* resp = resps->resps[i];
if (!resp)
continue;
if (resp->type == req_type && resp->req == req) {
*response_length = resp->len;
if (*response_length != 0)
*response_data = &resp->data[0];
else
*response_data = NULL;
return true;
}
}
if (resps && resps->generic) {
*response_data = &resps->generic->data[0];
*response_length = resps->generic->len;
return true;
}
}
return false;
}
#define UDC_NAME_LENGTH_MAX 128
struct usb_raw_init {
__u8 driver_name[UDC_NAME_LENGTH_MAX];
__u8 device_name[UDC_NAME_LENGTH_MAX];
__u8 speed;
};
enum usb_raw_event_type {
USB_RAW_EVENT_INVALID = 0,
USB_RAW_EVENT_CONNECT = 1,
USB_RAW_EVENT_CONTROL = 2,
};
struct usb_raw_event {
__u32 type;
__u32 length;
__u8 data[0];
};
struct usb_raw_ep_io {
__u16 ep;
__u16 flags;
__u32 length;
__u8 data[0];
};
#define USB_RAW_EPS_NUM_MAX 30
#define USB_RAW_EP_NAME_MAX 16
#define USB_RAW_EP_ADDR_ANY 0xff
struct usb_raw_ep_caps {
__u32 type_control : 1;
__u32 type_iso : 1;
__u32 type_bulk : 1;
__u32 type_int : 1;
__u32 dir_in : 1;
__u32 dir_out : 1;
};
struct usb_raw_ep_limits {
__u16 maxpacket_limit;
__u16 max_streams;
__u32 reserved;
};
struct usb_raw_ep_info {
__u8 name[USB_RAW_EP_NAME_MAX];
__u32 addr;
struct usb_raw_ep_caps caps;
struct usb_raw_ep_limits limits;
};
struct usb_raw_eps_info {
struct usb_raw_ep_info eps[USB_RAW_EPS_NUM_MAX];
};
#define USB_RAW_IOCTL_INIT _IOW('U', 0, struct usb_raw_init)
#define USB_RAW_IOCTL_RUN _IO('U', 1)
#define USB_RAW_IOCTL_EVENT_FETCH _IOR('U', 2, struct usb_raw_event)
#define USB_RAW_IOCTL_EP0_WRITE _IOW('U', 3, struct usb_raw_ep_io)
#define USB_RAW_IOCTL_EP0_READ _IOWR('U', 4, struct usb_raw_ep_io)
#define USB_RAW_IOCTL_EP_ENABLE _IOW('U', 5, struct usb_endpoint_descriptor)
#define USB_RAW_IOCTL_EP_DISABLE _IOW('U', 6, __u32)
#define USB_RAW_IOCTL_EP_WRITE _IOW('U', 7, struct usb_raw_ep_io)
#define USB_RAW_IOCTL_EP_READ _IOWR('U', 8, struct usb_raw_ep_io)
#define USB_RAW_IOCTL_CONFIGURE _IO('U', 9)
#define USB_RAW_IOCTL_VBUS_DRAW _IOW('U', 10, __u32)
#define USB_RAW_IOCTL_EPS_INFO _IOR('U', 11, struct usb_raw_eps_info)
#define USB_RAW_IOCTL_EP0_STALL _IO('U', 12)
#define USB_RAW_IOCTL_EP_SET_HALT _IOW('U', 13, __u32)
#define USB_RAW_IOCTL_EP_CLEAR_HALT _IOW('U', 14, __u32)
#define USB_RAW_IOCTL_EP_SET_WEDGE _IOW('U', 15, __u32)
static int usb_raw_open()
{
return open("/dev/raw-gadget", O_RDWR);
}
static int usb_raw_init(int fd, uint32_t speed, const char* driver, const char* device)
{
struct usb_raw_init arg;
strncpy((char*)&arg.driver_name[0], driver, sizeof(arg.driver_name));
strncpy((char*)&arg.device_name[0], device, sizeof(arg.device_name));
arg.speed = speed;
return ioctl(fd, USB_RAW_IOCTL_INIT, &arg);
}
static int usb_raw_run(int fd)
{
return ioctl(fd, USB_RAW_IOCTL_RUN, 0);
}
static int usb_raw_ep_write(int fd, struct usb_raw_ep_io* io)
{
return ioctl(fd, USB_RAW_IOCTL_EP_WRITE, io);
}
static int usb_raw_ep_read(int fd, struct usb_raw_ep_io* io)
{
return ioctl(fd, USB_RAW_IOCTL_EP_READ, io);
}
static int usb_raw_configure(int fd)
{
return ioctl(fd, USB_RAW_IOCTL_CONFIGURE, 0);
}
static int usb_raw_vbus_draw(int fd, uint32_t power)
{
return ioctl(fd, USB_RAW_IOCTL_VBUS_DRAW, power);
}
static int usb_raw_ep0_write(int fd, struct usb_raw_ep_io* io)
{
return ioctl(fd, USB_RAW_IOCTL_EP0_WRITE, io);
}
static int usb_raw_ep0_read(int fd, struct usb_raw_ep_io* io)
{
return ioctl(fd, USB_RAW_IOCTL_EP0_READ, io);
}
static int usb_raw_event_fetch(int fd, struct usb_raw_event* event)
{
return ioctl(fd, USB_RAW_IOCTL_EVENT_FETCH, event);
}
static int usb_raw_ep_enable(int fd, struct usb_endpoint_descriptor* desc)
{
return ioctl(fd, USB_RAW_IOCTL_EP_ENABLE, desc);
}
static int usb_raw_ep_disable(int fd, int ep)
{
return ioctl(fd, USB_RAW_IOCTL_EP_DISABLE, ep);
}
static int usb_raw_ep0_stall(int fd)
{
return ioctl(fd, USB_RAW_IOCTL_EP0_STALL, 0);
}
static int lookup_interface(int fd, uint8_t bInterfaceNumber, uint8_t bAlternateSetting)
{
struct usb_device_index* index = lookup_usb_index(fd);
if (!index)
return -1;
for (int i = 0; i < index->ifaces_num; i++) {
if (index->ifaces[i].bInterfaceNumber == bInterfaceNumber &&
index->ifaces[i].bAlternateSetting == bAlternateSetting)
return i;
}
return -1;
}
static int lookup_endpoint(int fd, uint8_t bEndpointAddress)
{
struct usb_device_index* index = lookup_usb_index(fd);
if (!index)
return -1;
if (index->iface_cur < 0)
return -1;
for (int ep = 0; ep < index->ifaces[index->iface_cur].eps_num; ep++)
if (index->ifaces[index->iface_cur].eps[ep].desc.bEndpointAddress == bEndpointAddress)
return index->ifaces[index->iface_cur].eps[ep].handle;
return -1;
}
#define USB_MAX_PACKET_SIZE 4096
struct usb_raw_control_event {
struct usb_raw_event inner;
struct usb_ctrlrequest ctrl;
char data[USB_MAX_PACKET_SIZE];
};
struct usb_raw_ep_io_data {
struct usb_raw_ep_io inner;
char data[USB_MAX_PACKET_SIZE];
};
static void set_interface(int fd, int n)
{
struct usb_device_index* index = lookup_usb_index(fd);
if (!index)
return;
if (index->iface_cur >= 0 && index->iface_cur < index->ifaces_num) {
for (int ep = 0; ep < index->ifaces[index->iface_cur].eps_num; ep++) {
int rv = usb_raw_ep_disable(fd, index->ifaces[index->iface_cur].eps[ep].handle);
if (rv < 0) {
} else {
}
}
}
if (n >= 0 && n < index->ifaces_num) {
for (int ep = 0; ep < index->ifaces[n].eps_num; ep++) {
int rv = usb_raw_ep_enable(fd, &index->ifaces[n].eps[ep].desc);
if (rv < 0) {
} else {
index->ifaces[n].eps[ep].handle = rv;
}
}
index->iface_cur = n;
}
}
static int configure_device(int fd)
{
struct usb_device_index* index = lookup_usb_index(fd);
if (!index)
return -1;
int rv = usb_raw_vbus_draw(fd, index->bMaxPower);
if (rv < 0) {
return rv;
}
rv = usb_raw_configure(fd);
if (rv < 0) {
return rv;
}
set_interface(fd, 0);
return 0;
}
static volatile long syz_usb_connect_impl(uint64_t speed, uint64_t dev_len, const char* dev,
const struct vusb_connect_descriptors* descs,
lookup_connect_out_response_t lookup_connect_response_out)
{
if (!dev) {
return -1;
}
int fd = usb_raw_open();
if (fd < 0) {
return fd;
}
if (fd >= MAX_FDS) {
close(fd);
return -1;
}
struct usb_device_index* index = add_usb_index(fd, dev, dev_len);
if (!index) {
return -1;
}
char device[32];
sprintf(&device[0], "dummy_udc.%llu", procid);
int rv = usb_raw_init(fd, speed, "dummy_udc", &device[0]);
if (rv < 0) {
return rv;
}
rv = usb_raw_run(fd);
if (rv < 0) {
return rv;
}
bool done = false;
while (!done) {
struct usb_raw_control_event event;
event.inner.type = 0;
event.inner.length = sizeof(event.ctrl);
rv = usb_raw_event_fetch(fd, (struct usb_raw_event*)&event);
if (rv < 0) {
return rv;
}
if (event.inner.type != USB_RAW_EVENT_CONTROL)
continue;
char* response_data = NULL;
uint32_t response_length = 0;
struct usb_qualifier_descriptor qual;
if (event.ctrl.bRequestType & USB_DIR_IN) {
if (!lookup_connect_response_in(fd, descs, &event.ctrl, &qual, &response_data, &response_length)) {
usb_raw_ep0_stall(fd);
continue;
}
} else {
if (!lookup_connect_response_out(fd, descs, &event.ctrl, &done)) {
usb_raw_ep0_stall(fd);
continue;
}
response_data = NULL;
response_length = event.ctrl.wLength;
}
if ((event.ctrl.bRequestType & USB_TYPE_MASK) == USB_TYPE_STANDARD &&
event.ctrl.bRequest == USB_REQ_SET_CONFIGURATION) {
rv = configure_device(fd);
if (rv < 0) {
return rv;
}
}
struct usb_raw_ep_io_data response;
response.inner.ep = 0;
response.inner.flags = 0;
if (response_length > sizeof(response.data))
response_length = 0;
if (event.ctrl.wLength < response_length)
response_length = event.ctrl.wLength;
response.inner.length = response_length;
if (response_data)
memcpy(&response.data[0], response_data, response_length);
else
memset(&response.data[0], 0, response_length);
if (event.ctrl.bRequestType & USB_DIR_IN) {
rv = usb_raw_ep0_write(fd, (struct usb_raw_ep_io*)&response);
} else {
rv = usb_raw_ep0_read(fd, (struct usb_raw_ep_io*)&response);
}
if (rv < 0) {
return rv;
}
}
sleep_ms(200);
return fd;
}
static volatile long syz_usb_connect(volatile long a0, volatile long a1, volatile long a2, volatile long a3)
{
uint64_t speed = a0;
uint64_t dev_len = a1;
const char* dev = (const char*)a2;
const struct vusb_connect_descriptors* descs = (const struct vusb_connect_descriptors*)a3;
return syz_usb_connect_impl(speed, dev_len, dev, descs, &lookup_connect_response_out_generic);
}
static volatile long syz_usb_control_io(volatile long a0, volatile long a1, volatile long a2)
{
int fd = a0;
const struct vusb_descriptors* descs = (const struct vusb_descriptors*)a1;
const struct vusb_responses* resps = (const struct vusb_responses*)a2;
struct usb_raw_control_event event;
event.inner.type = 0;
event.inner.length = USB_MAX_PACKET_SIZE;
int rv = usb_raw_event_fetch(fd, (struct usb_raw_event*)&event);
if (rv < 0) {
return rv;
}
if (event.inner.type != USB_RAW_EVENT_CONTROL) {
return -1;
}
char* response_data = NULL;
uint32_t response_length = 0;
if ((event.ctrl.bRequestType & USB_DIR_IN) && event.ctrl.wLength) {
if (!lookup_control_response(descs, resps, &event.ctrl, &response_data, &response_length)) {
usb_raw_ep0_stall(fd);
return -1;
}
} else {
if ((event.ctrl.bRequestType & USB_TYPE_MASK) == USB_TYPE_STANDARD ||
event.ctrl.bRequest == USB_REQ_SET_INTERFACE) {
int iface_num = event.ctrl.wIndex;
int alt_set = event.ctrl.wValue;
int iface_index = lookup_interface(fd, iface_num, alt_set);
if (iface_index < 0) {
} else {
set_interface(fd, iface_index);
}
}
response_length = event.ctrl.wLength;
}
struct usb_raw_ep_io_data response;
response.inner.ep = 0;
response.inner.flags = 0;
if (response_length > sizeof(response.data))
response_length = 0;
if (event.ctrl.wLength < response_length)
response_length = event.ctrl.wLength;
if ((event.ctrl.bRequestType & USB_DIR_IN) && !event.ctrl.wLength) {
response_length = USB_MAX_PACKET_SIZE;
}
response.inner.length = response_length;
if (response_data)
memcpy(&response.data[0], response_data, response_length);
else
memset(&response.data[0], 0, response_length);
if ((event.ctrl.bRequestType & USB_DIR_IN) && event.ctrl.wLength) {
rv = usb_raw_ep0_write(fd, (struct usb_raw_ep_io*)&response);
} else {
rv = usb_raw_ep0_read(fd, (struct usb_raw_ep_io*)&response);
}
if (rv < 0) {
return rv;
}
sleep_ms(200);
return 0;
}
static volatile long syz_usb_ep_write(volatile long a0, volatile long a1, volatile long a2, volatile long a3)
{
int fd = a0;
uint8_t ep = a1;
uint32_t len = a2;
char* data = (char*)a3;
int ep_handle = lookup_endpoint(fd, ep);
if (ep_handle < 0) {
return -1;
}
struct usb_raw_ep_io_data io_data;
io_data.inner.ep = ep_handle;
io_data.inner.flags = 0;
if (len > sizeof(io_data.data))
len = sizeof(io_data.data);
io_data.inner.length = len;
memcpy(&io_data.data[0], data, len);
int rv = usb_raw_ep_write(fd, (struct usb_raw_ep_io*)&io_data);
if (rv < 0) {
return rv;
}
sleep_ms(200);
return 0;
}
static volatile long syz_usb_ep_read(volatile long a0, volatile long a1, volatile long a2, volatile long a3)
{
int fd = a0;
uint8_t ep = a1;
uint32_t len = a2;
char* data = (char*)a3;
int ep_handle = lookup_endpoint(fd, ep);
if (ep_handle < 0) {
return -1;
}
struct usb_raw_ep_io_data io_data;
io_data.inner.ep = ep_handle;
io_data.inner.flags = 0;
if (len > sizeof(io_data.data))
len = sizeof(io_data.data);
io_data.inner.length = len;
int rv = usb_raw_ep_read(fd, (struct usb_raw_ep_io*)&io_data);
if (rv < 0) {
return rv;
}
memcpy(&data[0], &io_data.data[0], io_data.inner.length);
sleep_ms(200);
return 0;
}
static long syz_open_dev(volatile long a0, volatile long a1, volatile long a2)
{
if (a0 == 0xc || a0 == 0xb) {
char buf[128];
sprintf(buf, "/dev/%s/%d:%d", a0 == 0xc ? "char" : "block", (uint8_t)a1, (uint8_t)a2);
return open(buf, O_RDWR, 0);
} else {
unsigned long nb = a1;
char buf[1024];
char* hash;
strncpy(buf, (char*)a0, sizeof(buf) - 1);
buf[sizeof(buf) - 1] = 0;
while ((hash = strchr(buf, '#'))) {
*hash = '0' + (char)(nb % 10);
nb /= 10;
}
return open(buf, a2 & ~O_CREAT, 0);
}
}
uint64_t r[2] = {0xffffffffffffffff, 0xffffffffffffffff};
int main(void)
{
syscall(__NR_mmap, /*addr=*/0x1ffffffff000ul, /*len=*/0x1000, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul);
syscall(__NR_mmap, /*addr=*/0x200000000000ul, /*len=*/0x1000000, /*prot=PROT_WRITE|PROT_READ|PROT_EXEC*/7ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul);
syscall(__NR_mmap, /*addr=*/0x200001000000ul, /*len=*/0x1000, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul);
const char* reason;
(void)reason;
intptr_t res = 0;
if (write(1, "executing program\n", sizeof("executing program\n") - 1)) {}
// syz_usb_connect arguments: [
// speed: usb_device_speed = 0x3 (8 bytes)
// dev_len: len = 0x40 (8 bytes)
// dev: ptr[inout, array[ANYUNION]] {
// array[ANYUNION] {
// union ANYUNION {
// ANYBLOB: buffer: {12 01 00 02 00 00 00 40 72 05 fe ca 00 01 00 00 00 01 09 02 2e 00 01 01 00 80 fa 09 04 00 00 04 ff 00 00 00 07 05 01 02 00 02 00 07 05 81 02 00 02 00 07 05 02 02 00 02 00 07 05 82 02 00 02} (length 0x3f)
// }
// }
// }
// conn_descs: nil
// ]
// returns fd_usb
memcpy((void*)0x200000000000, "... [truncated large byte array] ...", 63);
res = -1;
res = syz_usb_connect(/*speed=USB_SPEED_HIGH*/3, /*dev_len=*/0x40, /*dev=*/0x200000000000, /*conn_descs=*/0);
if (res != -1)
r[0] = res;
// syz_usb_ep_read arguments: [
// fd: fd_usb (resource)
// ep: int8 = 0x1 (1 bytes)
// len: len = 0x0 (8 bytes)
// data: nil
// ]
syz_usb_ep_read(/*fd=*/r[0], /*ep=*/1, /*len=*/0, /*data=*/0);
// syz_usb_ep_write arguments: [
// fd: fd_usb (resource)
// ep: int8 = 0x81 (1 bytes)
// len: len = 0x40 (8 bytes)
// data: ptr[in, buffer] {
// buffer: {90 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00} (length 0x40)
// }
// ]
memcpy((void*)0x200000000100, "... [truncated large byte array] ...", 64);
syz_usb_ep_write(/*fd=*/r[0], /*ep=*/0x81, /*len=*/0x40, /*data=*/0x200000000100);
// syz_usb_ep_write arguments: [
// fd: fd_usb (resource)
// ep: int8 = 0x81 (1 bytes)
// len: len = 0x40 (8 bytes)
// data: ptr[in, buffer] {
// buffer: {91 01 00 00 00 11 22 33 44 55 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00} (length 0x40)
// }
// ]
memcpy((void*)0x200000000300, "... [truncated large byte array] ...", 64);
syz_usb_ep_write(/*fd=*/r[0], /*ep=*/0x81, /*len=*/0x40, /*data=*/0x200000000300);
// syz_usb_ep_read arguments: [
// fd: fd_usb (resource)
// ep: int8 = 0x1 (1 bytes)
// len: len = 0x0 (8 bytes)
// data: nil
// ]
syz_usb_ep_read(/*fd=*/r[0], /*ep=*/1, /*len=*/0, /*data=*/0);
// syz_open_dev$evdev arguments: [
// dev: ptr[in, buffer] {
// buffer: {2f 64 65 76 2f 69 6e 70 75 74 2f 65 76 65 6e 74 23 00} (length 0x12)
// }
// id: intptr = 0x2 (8 bytes)
// flags: open_flags = 0x0 (8 bytes)
// ]
// returns fd_evdev
memcpy((void*)0x200000000040, "/dev/input/event#\000", 18);
res = -1;
res = syz_open_dev(/*dev=*/0x200000000040, /*id=*/2, /*flags=*/0);
if (res != -1)
r[1] = res;
// ioctl$EVIOCGMASK arguments: [
// fd: fd_evdev (resource)
// cmd: const = 0x80104592 (4 bytes)
// arg: ptr[in, input_mask] {
// input_mask {
// type: input_codes = 0x0 (4 bytes)
// size: bytesize = 0xffffffffffffff36 (4 bytes)
// ptr: ptr[in, buffer] {
// buffer: {95 2b b3 e0 06 ae 9a 4c 3a} (length 0x9)
// }
// }
// }
// ]
*(uint32_t*)0x200000000300 = 0;
*(uint32_t*)0x200000000304 = 0xffffff36;
*(uint64_t*)0x200000000308 = 0x200000000200;
memcpy((void*)0x200000000200, "\x95\x2b\xb3\xe0\x06\xae\x9a\x4c\x3a", 9);
syscall(__NR_ioctl, /*fd=*/r[1], /*cmd=*/0x80104592, /*arg=*/0x200000000300ul);
// syz_usb_control_io$hid arguments: [
// fd: fd_usb_hid (resource)
// descs: nil
// resps: nil
// ]
syz_usb_control_io(/*fd=*/r[0], /*descs=*/0, /*resps=*/0);
return 0;
}
Reply: The root cause of this bug is that `cxacru_cm()` leaves `rcv_urb` active if it encounters an error while submitting or waiting for `snd_urb`.
Here is the exact sequence of events that leads to the crash:
1. `cxacru_atm_start()` calls `cxacru_cm()` to send the `CM_REQUEST_CHIP_ADSL_LINE_START` (`0x84`) command.
2. Inside `cxacru_cm()`, `rcv_urb` is successfully submitted first (line 631).
3. Then, `snd_urb` is submitted and `cxacru_cm()` waits for its completion via `cxacru_start_wait_urb()` (line 657).
4. In the syzkaller reproducer, the USB device behaves unexpectedly (e.g., endpoint stall or disconnect), causing `snd_urb` to complete with an error status of `-104` (`-ECONNRESET`).
5. `cxacru_start_wait_urb()` returns this `-104` error, which prompts `cxacru_cm()` to print `"send of cm 0x84 failed (-104)"` and jump to the `fail:` label (line 661).
6. At the `fail:` label, `cxacru_cm()` simply unlocks the mutex and returns the error, **leaving `rcv_urb` still active and pending**.
7. Back in `cxacru_atm_start()`, the error is printed (`"CHIP_ADSL_LINE_START returned -104"`) but ignored, and the driver proceeds to start status polling by calling `cxacru_poll_status()`.
8. `cxacru_poll_status()` immediately calls `cxacru_cm_get_array()`, which invokes `cxacru_cm()` again.
9. `cxacru_cm()` attempts to submit `rcv_urb` again, but since it was never unlinked or waited for in the previous failed call, it is still active. This triggers the `URB ... submitted while active` warning in `usb_submit_urb()`.
### Fix
To fix this bug, we need to ensure that `rcv_urb` is properly killed if `cxacru_cm()` aborts early. We can safely call `usb_kill_urb()` on `rcv_urb` in the error path. `usb_kill_urb()` is safe to call even if the URB is not active (e.g., if it failed to submit in the first place, or if it already completed), so it can be called unconditionally on error.
```c
--- a/drivers/usb/atm/cxacru.c
+++ b/drivers/usb/atm/cxacru.c
@@ -700,6 +700,8 @@ static int cxacru_cm(struct cxacru_data *instance, enum cxacru_cm_request cm,
ret = offd;
usb_dbg(instance->usbatm, "cm %#x\n", cm);
fail:
+ if (ret < 0)
+ usb_kill_urb(instance->rcv_urb);
mutex_unlock(&instance->cm_serialize);
err:
return ret;
```
|
| 8/2 |
2026/07/31 07:15 |
llm |
debugger |
0m
Model:
Tokens:
input: 17049
output: 23
thoughts: 363
Thoughts: **Crash Analysis: URB Submission Issue**
Okay, so we've got a crash, and the log points to a problem with a URB (USB Request Block) being submitted while active. The kernel is complaining in `drivers/usb/core/urb.c` at line 379. This is interesting β it's a classic race condition or improper handling of URBs. CPU #1, kworker/1:1, process 5258 is the culprit.
The call trace is crucial here. Let's break it down: The crash originates within the `cxacru_cm` function, which then calls `cxacru_cm_get_array` and eventually leads to a problem with polling status via `cxacru_poll_status`, and we arrive at the start of atm.
Looking at the trace, the `cxacru` driver is involved, specifically functions like `cxacru_atm_start`, `usbatm_atm_init`, `usbatm_usb_probe`, and `cxacru_usb_probe`. These functions are all part of the USB ATM subsystem, which is not something I see often now. This suggests a problem with how the driver is managing its USB communication, likely related to URB submission and completion. Specifically, this is a Conexant AccessRunner USB device.
My next step is to deep-dive into the source code, especially focusing on `drivers/usb/atm/cxacru.c` and `drivers/usb/atm/usbatm.c`. I need to understand the control flow, specifically how URBs are submitted, canceled, and handled in the context of the device's polling and status updates. I'll be looking for potential race conditions, incorrect locking, or other synchronization issues that could cause an active URB to be resubmitted. We might have to consider locking, memory access and atomic access, as well as the possible of concurrency issues that come with using different driver stacks. I am also aware that this is a dated card, as atm is an older technology.
|
| 9/2 |
2026/07/31 07:16 |
tool |
codesearch-definition-source |
0m
Args:
Results: map[SourceCode: 608: static int cxacru_cm(struct cxacru_data *instance, enum cxacru_cm_request cm,
609: u8 *wdata, int wsize, u8 *rdata, int rsize)
610: {
611: int ret, actlen;
612: int offb, offd;
613: const int stride = CMD_PACKET_SIZE - 4;
614: u8 *wbuf = instance->snd_buf;
615: u8 *rbuf = instance->rcv_buf;
616: int wbuflen = ((wsize - 1) / stride + 1) * CMD_PACKET_SIZE;
617: int rbuflen = ((rsize - 1) / stride + 1) * CMD_PACKET_SIZE;
618:
619: if (wbuflen > PAGE_SIZE || rbuflen > PAGE_SIZE) {
620: if (printk_ratelimit())
621: usb_err(instance->usbatm, "requested transfer size too large (%d, %d)\n",
622: wbuflen, rbuflen);
623: ret = -ENOMEM;
624: goto err;
625: }
626:
627: mutex_lock(&instance->cm_serialize);
628:
629: /* submit reading urb before the writing one */
630: init_completion(&instance->rcv_done);
631: ret = usb_submit_urb(instance->rcv_urb, GFP_KERNEL);
632: if (ret < 0) {
633: if (printk_ratelimit())
634: usb_err(instance->usbatm, "submit of read urb for cm %#x failed (%d)\n",
635: cm, ret);
636: goto fail;
637: }
638:
639: memset(wbuf, 0, wbuflen);
640: /* handle wsize == 0 */
641: wbuf[0] = cm;
642: for (offb = offd = 0; offd < wsize; offd += stride, offb += CMD_PACKET_SIZE) {
643: wbuf[offb] = cm;
644: memcpy(wbuf + offb + 4, wdata + offd, min_t(int, stride, wsize - offd));
645: }
646:
647: instance->snd_urb->transfer_buffer_length = wbuflen;
648: init_completion(&instance->snd_done);
649: ret = usb_submit_urb(instance->snd_urb, GFP_KERNEL);
650: if (ret < 0) {
651: if (printk_ratelimit())
652: usb_err(instance->usbatm, "submit of write urb for cm %#x failed (%d)\n",
653: cm, ret);
654: goto fail;
655: }
656:
657: ret = cxacru_start_wait_urb(instance->snd_urb, &instance->snd_done, NULL);
658: if (ret < 0) {
659: if (printk_ratelimit())
660: usb_err(instance->usbatm, "send of cm %#x failed (%d)\n", cm, ret);
661: goto fail;
662: }
663:
664: ret = cxacru_start_wait_urb(instance->rcv_urb, &instance->rcv_done, &actlen);
665: if (ret < 0) {
666: if (printk_ratelimit())
667: usb_err(instance->usbatm, "receive of cm %#x failed (%d)\n", cm, ret);
668: goto fail;
669: }
670: if (actlen % CMD_PACKET_SIZE || !actlen) {
671: if (printk_ratelimit())
672: usb_err(instance->usbatm, "invalid response length to cm %#x: %d\n",
673: cm, actlen);
674: ret = -EIO;
675: goto fail;
676: }
677:
678: /* check the return status and copy the data to the output buffer, if needed */
679: for (offb = offd = 0; offd < rsize && offb < actlen; offb += CMD_PACKET_SIZE) {
680: if (rbuf[offb] != cm) {
681: if (printk_ratelimit())
682: usb_err(instance->usbatm, "wrong cm %#x in response to cm %#x\n",
683: rbuf[offb], cm);
684: ret = -EIO;
685: goto fail;
686: }
687: if (rbuf[offb + 1] != CM_STATUS_SUCCESS) {
688: if (printk_ratelimit())
689: usb_err(instance->usbatm, "response to cm %#x failed: %#x\n",
690: cm, rbuf[offb + 1]);
691: ret = -EIO;
692: goto fail;
693: }
694: if (offd >= rsize)
695: break;
696: memcpy(rdata + offd, rbuf + offb + 4, min_t(int, stride, rsize - offd));
697: offd += stride;
698: }
699:
700: ret = offd;
701: usb_dbg(instance->usbatm, "cm %#x\n", cm);
702: fail:
703: mutex_unlock(&instance->cm_serialize);
704: err:
705: return ret;
706: }
SourceFile:drivers/usb/atm/cxacru.c]
|
| 10/2 |
2026/07/31 07:16 |
llm |
debugger |
0m
Model:
Tokens:
input: 19607
output: 27
thoughts: 117
Thoughts: **Analyzing a USB Crash**
Okay, so I'm looking at this crash, and the backtrace points directly to `cxacru_cm+0x21a/0xf10` in `drivers/usb/atm/cxacru.c:631`. That line is where we're submitting the URB β specifically, `ret = usb_submit_urb(instance->rcv_urb, GFP_KERNEL);`. The critical warning here is "URB ffff88812658d200 submitted while active." Right, so that tells me that `instance->rcv_urb` is *already* active when we're trying to submit it again. That's the problem. We're submitting an URB that's still outstanding.
My next step is to examine `cxacru_start_wait_urb`. Let's see how that URB is being handled to understand the timing and sequencing and to identify *why* it's active when it shouldn't be. I need to understand how we are starting, stopping, and resubmitting this URB to figure out where the logic has gone wrong and fix the race condition that's causing this.
|
| 11/2 |
2026/07/31 07:16 |
tool |
codesearch-definition-source |
0m
Args: map[Name:cxacru_start_wait_urb]
Results: map[SourceCode: 590: static int cxacru_start_wait_urb(struct urb *urb, struct completion *done,
591: int *actual_length)
592: {
593: struct cxacru_timer timer = {
594: .urb = urb,
595: };
596:
597: timer_setup_on_stack(&timer.timer, cxacru_timeout_kill, 0);
598: mod_timer(&timer.timer, jiffies + msecs_to_jiffies(CMD_TIMEOUT));
599: wait_for_completion(done);
600: timer_delete_sync(&timer.timer);
601: timer_destroy_on_stack(&timer.timer);
602:
603: if (actual_length)
604: *actual_length = urb->actual_length;
605: return urb->status; /* must read status after completion */
606: }
SourceFile:drivers/usb/atm/cxacru.c]
|
| 12/2 |
2026/07/31 07:16 |
llm |
debugger |
0m
Model:
Tokens:
input: 20318
output: 25
thoughts: 763
Thoughts: **Analyzing Potential Race Conditions in `cxacru_cm`**
Okay, let's break this down. My initial thought is that `cxacru_start_wait_urb` seems to be the key to synchronizing the URB submissions and completions. Specifically, I'm concerned about the error handling within `cxacru_cm`.
I see that `cxacru_start_wait_urb` is used to wait for `done`, as the text states. The flow is as follows: If `cxacru_cm` fails during the submission of the send urb, it jumps to `fail:`, unlocking the mutex and returning. I notice a significant issue here: if the `snd_urb` submission fails *or* if `cxacru_start_wait_urb` for the `snd_urb` fails (likely due to a timeout), it still jumps to `fail:`. The problem is that the `rcv_urb` has already been submitted *before* the `snd_urb` is submitted.
The critical vulnerability is this: if either the submission or the wait on `snd_urb` fails (e.g., timeout), the `rcv_urb` remains active. This would lead to a problem because the next time we enter `cxacru_cm`, the routine is still active. If we re-enter `cxacru_cm`, it will attempt to submit `rcv_urb` *again*, while the *old* `rcv_urb` is still active. This is a classic double submission of a USB request, which will cause a crash.
I need to confirm the timing of this further.
Looking at the code, it's clear: `usb_submit_urb(instance->rcv_urb, GFP_KERNEL)` is called *before* the `snd_urb`. So, `rcv_urb` is submitted first. The code then handles the data transfer for the `snd_urb` and submits that. Crucially, if there's a problem with the `snd_urb` (either submission or timeout), the code jumps to the `fail:` label.
The critical issue is the same: the `rcv_urb` stays active but is not managed correctly by the failure condition.
I need to investigate what `cxacru_start_wait_urb` does in case of timeout or other urb error conditions to confirm the nature of this urb race. Does it use the timeout to kill the URB in question?
|
| 13/2 |
2026/07/31 07:16 |
tool |
codesearch-definition-source |
0m
Args: map[Name:cxacru_timeout_kill]
Results: map[SourceCode: 583: static void cxacru_timeout_kill(struct timer_list *t)
584: {
585: struct cxacru_timer *timer = timer_container_of(timer, t, timer);
586:
587: usb_unlink_urb(timer->urb);
588: }
SourceFile:drivers/usb/atm/cxacru.c]
|
| 14/2 |
2026/07/31 07:16 |
llm |
debugger |
0m
Model:
Tokens:
input: 21762
output: 23
thoughts: 692
Thoughts: **Analyzing the `cxacru_cm` Error Handling**
Okay, let's break this down. My initial thought is that `cxacru_timeout_kill` unlinks the `snd_urb` in the case of a timeout, which is expected behavior. This triggers the completion handler, and `cxacru_start_wait_urb` then returns `urb->status`, likely `-ENOENT` or `-ECONNRESET`. `cxacru_cm` rightfully checks for the negative return value (`ret < 0`) and jumps to `fail:`. The critical point is that the `rcv_urb`, which was submitted *before* the `snd_urb`, is *never* unlinked in this scenario! This is my first red flag.
If the `snd_urb` submission fails, *or* if it times out, the `rcv_urb` is left hanging. Then, the next time `cxacru_cm` runs, it tries to resubmit that now-stale `rcv_urb`, triggering the warning. This is precisely the problem.
My immediate next step is to examine the `fail:` path. Let's see if there's any attempt at cleaning up the `rcv_urb` there. But, nope. The code simply unlocks the mutex and returns.
Now, I'm thinking, what happens if `usb_submit_urb(instance->snd_urb)` *itself* fails? The `rcv_urb` is still active. Similarly, if `cxacru_start_wait_urb(instance->snd_urb)` fails, the `rcv_urb` is *still* active.
Okay, clearly, we need a `usb_kill_urb`. If `snd_urb` fails, we need to immediately kill the `rcv_urb`. That's the obvious fix.
But, wait, what if `cxacru_start_wait_urb(instance->rcv_urb)` fails? If it *times out*, `cxacru_timeout_kill` *does* unlink the `rcv_urb`, so that is handled. However, if `snd_urb` fails, the `rcv_urb` is never even *waited* for, nor is it unlinked.
Let's look at `cxacru_cm`'s code again.
```c
ret = usb_submit_urb(instance->snd_urb, GFP_KERNEL);
if (ret < 0) {
if (printk_ratelimit())
usb_err(instance->usbatm, "submit of write urb for cm %#x failed (%d)\n",
cm, ret);
goto fail;
}
ret = cxacru_start_wait_urb(instance->snd_urb, &instance->snd_done, NULL);
if (ret < 0) {
if (printk_ratelimit())
usb_err(instance->usbatm, "send of cm %#x failed (%d)\n", cm, ret);
goto fail;
}
```
If *either* of those submissions fail, we jump to `fail:`. It's pretty clear: we need to insert a `usb_kill_urb(instance->rcv_urb)` *before* the `goto fail;` in both cases. Or at least in the top error path. Time to examine how `cxacru_cm` is used to confirm this.
|
| 15/2 |
2026/07/31 07:16 |
tool |
codesearch-find-references |
0m
Args:
Results: map[References:[map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:adsl_config_store SourceFile:drivers/usb/atm/cxacru.c SourceLine:481] map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:adsl_state_store SourceFile:drivers/usb/atm/cxacru.c SourceLine:357] map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:adsl_state_store SourceFile:drivers/usb/atm/cxacru.c SourceLine:377] map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:cxacru_atm_start SourceFile:drivers/usb/atm/cxacru.c SourceLine:780] map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:cxacru_atm_start SourceFile:drivers/usb/atm/cxacru.c SourceLine:789] map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:cxacru_card_status SourceFile:drivers/usb/atm/cxacru.c SourceLine:760] map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:cxacru_cm_get_array SourceFile:drivers/usb/atm/cxacru.c SourceLine:722] map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:cxacru_heavy_init SourceFile:drivers/usb/atm/cxacru.c SourceLine:1100]] TruncatedOutput:false]
|
| 16/2 |
2026/07/31 07:16 |
llm |
debugger |
0m
Model:
Tokens:
input: 23690
output: 27
thoughts: 15
Thoughts: Okay, let's dive into this. Here's my take on those thoughts, as if they're my own:
**Analyzing `cxacru_cm_get_array`**
Alright, let's see what we've got here. My initial reaction is to pull up my mental schematics for the `cxacru_` namespace, immediately linking it to the core infrastructure of our current project. Given the naming convention, I can almost instantly infer that `cm` signifies some kind of Configuration Management. The function name, `get_array`, implies we're probably dealing with retrieving a structured set of data, likely a list or array, from the CM system. I need to figure out what data is being configured. Is it user preferences, server settings, deployment parameters, or something else entirely? The type of data will influence how I approach the code and the context in which I'll apply any of my expertise.
I'm already mentally running through potential concerns: What's the error handling like? How does it handle the retrieval failures? Is there a caching mechanism to avoid unnecessary calls to the CM system? What are the security implications? Does this function have a role in the authentication or authorization process? I'm going to have to look into all of these things. Finally, I need to know how this array is being used, so I can predict if this is going to be high-frequency access or something that is executed on occasion.
|
| 17/2 |
2026/07/31 07:16 |
tool |
codesearch-definition-source |
0m
Args: map[Name:cxacru_cm_get_array]
Results: map[SourceCode: 708: static int cxacru_cm_get_array(struct cxacru_data *instance, enum cxacru_cm_request cm,
709: u32 *data, int size)
710: {
711: int ret, len;
712: __le32 *buf;
713: int offb;
714: unsigned int offd;
715: const int stride = CMD_PACKET_SIZE / (4 * 2) - 1;
716: int buflen = ((size - 1) / stride + 1 + size * 2) * 4;
717:
718: buf = kmalloc(buflen, GFP_KERNEL);
719: if (!buf)
720: return -ENOMEM;
721:
722: ret = cxacru_cm(instance, cm, NULL, 0, (u8 *) buf, buflen);
723: if (ret < 0)
724: goto cleanup;
725:
726: /* len > 0 && len % 4 == 0 guaranteed by cxacru_cm() */
727: len = ret / 4;
728: for (offb = 0; offb < len; ) {
729: int l = le32_to_cpu(buf[offb++]);
730:
731: if (l < 0 || l > stride || l > (len - offb) / 2) {
732: if (printk_ratelimit())
733: usb_err(instance->usbatm, "invalid data length from cm %#x: %d\n",
734: cm, l);
735: ret = -EIO;
736: goto cleanup;
737: }
738: while (l--) {
739: offd = le32_to_cpu(buf[offb++]);
740: if (offd >= size) {
741: if (printk_ratelimit())
742: usb_err(instance->usbatm, "wrong index %#x in response to cm %#x\n",
743: offd, cm);
744: ret = -EIO;
745: goto cleanup;
746: }
747: data[offd] = le32_to_cpu(buf[offb++]);
748: }
749: }
750:
751: ret = 0;
752:
753: cleanup:
754: kfree(buf);
755: return ret;
756: }
SourceFile:drivers/usb/atm/cxacru.c]
|
| 18/2 |
2026/07/31 07:16 |
llm |
debugger |
0m
Model:
Tokens:
input: 24832
output: 22
thoughts: 47
Thoughts: Okay, here's my take on those thoughts, framed as my own:
**Analyzing a Potential USB Driver Bug**
Right, so I've got a USB driver issue on my hands, and it's looking pretty clear. The problem is that the `rcv_urb` isn't getting properly cleaned up if the `snd_urb` submission or completion goes sideways. That's a classic resource leak scenario, and those are always fun to debug (said with a hint of sarcasm, of course).
My next logical step is to pinpoint everywhere the `rcv_urb` is actually submitted. I need to make sure this isn't an issue originating from a secondary location. I'm going to track it back and then look at the edge cases, and start there. If I can establish the point of submission, I'll have a better understanding of how the failure happens and then I can dig into the control flow to see if there's an obvious missing `usb_kill_urb()` or similar cleanup call.
|
| 19/2 |
2026/07/31 07:16 |
tool |
codesearch-find-references |
0m
Error:
Args:
Results: map[References:<nil> TruncatedOutput:false]
|
| 20/2 |
2026/07/31 07:16 |
llm |
debugger |
0m
Model:
Tokens:
input: 25138
output: 23
thoughts: 13
Thoughts: Okay, let's dive into this. Here's my understanding, presented as a first-person account, tailored for someone who knows their stuff.
**Analyzing the `cxacru_data` Struct**
Alright, time to get my hands dirty. I need to get a clear picture of what's going on, and the place to start is the `cxacru_data` struct. I'm thinking, this is probably where the core data related to whatever process we're dealing with resides. Knowing the specifics of this struct is going to be crucial for understanding the overall flow and functionality. I need to break down each member, its data type, any associated comments, and figure out how they interact with each other. This struct will likely hold the keys to understanding what's happening at the fundamental level. Let's see what gems are hidden in this structure!
|
| 21/2 |
2026/07/31 07:17 |
tool |
codesearch-definition-source |
0m
Args:
Results: map[SourceCode: 170: struct cxacru_data {
171: struct usbatm_data *usbatm;
172:
173: const struct cxacru_modem_type *modem_type;
174:
175: int line_status;
176: struct mutex adsl_state_serialize;
177: int adsl_status;
178: struct delayed_work poll_work;
179: u32 card_info[CXINF_MAX];
180: struct mutex poll_state_serialize;
181: enum cxacru_poll_state poll_state;
182:
183: /* control handles */
184: struct mutex cm_serialize;
185: u8 *rcv_buf;
186: u8 *snd_buf;
187: struct urb *rcv_urb;
188: struct urb *snd_urb;
189: struct completion rcv_done;
190: struct completion snd_done;
191: };
SourceFile:drivers/usb/atm/cxacru.c]
|
| 22/2 |
2026/07/31 07:17 |
llm |
debugger |
0m
Model:
Tokens:
input: 25693
output: 28
thoughts: 20
Thoughts: Here's my attempt at summarizing the thought process, tailored for an expert audience:
**Analyzing URB Initialization**
Okay, so I'm diving into the USB stack code again, and my immediate focus is on understanding the initialization of `rcv_urb` and `snd_urb`. These URBs are the fundamental building blocks for USB transfers, so understanding how they're set up is crucial to understanding the underlying mechanism. I'm going to look closely at the places in the code where these structures are first created and populated. I need to figure out what data is being put into the descriptor, what queues they're getting associated with, and what conditions trigger their setup, because the structure is so important to everything that happens afterward. The initial conditions influence the future usage, and I'm looking for any early indicators of potential bottlenecks or design decisions that influence performance or behavior.
|
| 23/2 |
2026/07/31 07:17 |
tool |
codesearch-find-references |
0m
Args: map[Name:cxacru_data::rcv_urb]
Results: map[References:[map[ReferenceKind:writes ReferencingEntityKind:function ReferencingEntityName:cxacru_bind SourceFile:drivers/usb/atm/cxacru.c SourceLine:1159] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:cxacru_bind SourceFile:drivers/usb/atm/cxacru.c SourceLine:1160] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:cxacru_bind SourceFile:drivers/usb/atm/cxacru.c SourceLine:1189] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:cxacru_bind SourceFile:drivers/usb/atm/cxacru.c SourceLine:1199] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:cxacru_bind SourceFile:drivers/usb/atm/cxacru.c SourceLine:1224] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:cxacru_cm SourceFile:drivers/usb/atm/cxacru.c SourceLine:631] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:cxacru_cm SourceFile:drivers/usb/atm/cxacru.c SourceLine:664] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:cxacru_unbind SourceFile:drivers/usb/atm/cxacru.c SourceLine:1259] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:cxacru_unbind SourceFile:drivers/usb/atm/cxacru.c SourceLine:1261]] TruncatedOutput:false]
|
| 24/2 |
2026/07/31 07:17 |
llm |
debugger |
0m
Model:
Tokens:
input: 26428
output: 23
thoughts: 11
Thoughts: Okay, let's dive into this. Here's my take on those thoughts, as if they're my own:
**Analyzing `cxacru_unbind`**
Alright, `cxacru_unbind`... let's break this down. My initial reaction is to immediately consider its context. What's it bound *to*? What's the nature of this "bind" that needs to be "unbound"? I'm immediately thinking about resources, handles, or perhaps even network connections. The name itself suggests a function or method, likely within a system library or framework, as the naming convention feels specific, almost internally facing, rather than a user-friendly API.
Now I'm trying to mentally map this into known patterns. Is this about unbinding from a data structure? A particular communication endpoint? Is it resource management or a lifecycle management operation? Am I dealing with a C-style API, or something higher-level? The presence of "cru" in there makes me think this could be related to some sort of command or configuration aspect. The acronym seems to suggest *C*onfiguration, *R*esources, and *U*nbinding, at least as an initial hypothesis.
I need more information to really pin this down. Is there a related documentation, or an obvious place to look for that? If I were to approach this experimentally, I'd probably start by grepping the codebase for usage of related terms and functions to get a better feel. The goal would be to understand the complete cycle of action bound in order to effectively see its unbinding. Right now, this has me more curious than informed, so I will start looking for clues.
|
| 25/2 |
2026/07/31 07:17 |
tool |
codesearch-definition-source |
0m
Args:
Results: map[SourceCode:1230: static void cxacru_unbind(struct usbatm_data *usbatm_instance,
1231: struct usb_interface *intf)
1232: {
1233: struct cxacru_data *instance = usbatm_instance->driver_data;
1234: int is_polling = 1;
1235:
1236: usb_dbg(usbatm_instance, "cxacru_unbind entered\n");
1237:
1238: if (!instance) {
1239: usb_dbg(usbatm_instance, "cxacru_unbind: NULL instance!\n");
1240: return;
1241: }
1242:
1243: mutex_lock(&instance->poll_state_serialize);
1244: BUG_ON(instance->poll_state == CXPOLL_SHUTDOWN);
1245:
1246: /* ensure that status polling continues unless
1247: * it has already stopped */
1248: if (instance->poll_state == CXPOLL_STOPPED)
1249: is_polling = 0;
1250:
1251: /* stop polling from being stopped or started */
1252: instance->poll_state = CXPOLL_SHUTDOWN;
1253: mutex_unlock(&instance->poll_state_serialize);
1254:
1255: if (is_polling)
1256: cancel_delayed_work_sync(&instance->poll_work);
1257:
1258: usb_kill_urb(instance->snd_urb);
1259: usb_kill_urb(instance->rcv_urb);
1260: usb_free_urb(instance->snd_urb);
1261: usb_free_urb(instance->rcv_urb);
1262:
1263: free_page((unsigned long) instance->snd_buf);
1264: free_page((unsigned long) instance->rcv_buf);
1265:
1266: kfree(instance);
1267:
1268: usbatm_instance->driver_data = NULL;
1269: }
SourceFile:drivers/usb/atm/cxacru.c]
|
| 26/2 |
2026/07/31 07:17 |
llm |
debugger |
0m
Model:
Tokens:
input: 27450
output: 27
thoughts: 1534
Thoughts: **Analyzing the USB Communication Error in cxacru_cm**
Okay, so I've been tracing through this `cxacru_cm` function, and it looks like I've found a bug related to URB handling. `cxacru_unbind` is responsible for killing and freeing URBs, so it's not there. The issue is definitely within `cxacru_cm` itself.
Here's the problem: The code submits a read URB (`instance->rcv_urb`) first, then a write URB (`instance->snd_urb`). The write URB is submitted, and then the code waits for it. If there's an error during the *submission* of the write URB (e.g., `-ENODEV`, `-EPIPE`), the code jumps to the `fail:` label. But crucially, the read URB is already active! If the *wait* for the write URB fails (via `cxacru_start_wait_urb` returning a negative value), the same thing happens - the code jumps to `fail:` and the read URB is still active. There's no attempt to kill it in these error paths.
Specifically, if the submission of `instance->snd_urb` fails, the `rcv_urb` is left active. The same goes if the wait operation on `snd_urb` fails. The subsequent call to `cxacru_cm` will then attempt to resubmit the `rcv_urb` which is still active. This leads to the "URB ... submitted while active" warning and a `-EBUSY` error.
Essentially, `cxacru_start_wait_urb` returns the `urb->status`, and that's used to determine if the URB succeeded. If it times out, `cxacru_timeout_kill` unlinks the `snd_urb`. Then `cxacru_start_wait_urb` returns the status (typically `-ENOENT` or `-ECONNRESET`) and it jumps to `fail:`. However, the read URB is still active.
So, the fix is straightforward: In the error paths (`fail:`), I need to call `usb_kill_urb(instance->rcv_urb)` to ensure the read URB is cancelled if it was active. Specifically, I'll need to add it after any failure of `usb_submit_urb(instance->snd_urb)` or after the return from `cxacru_start_wait_urb(instance->snd_urb)`. The last case where `cxacru_start_wait_urb(instance->rcv_urb)` fails is fine - because `rcv_urb` will have already been unlinked. It's safe to call `usb_kill_urb` on it, in all cases.
So, the sequence goes like this: `cxacru_cm` is called. `usb_submit_urb(rcv_urb)` succeeds. Then, *either* `usb_submit_urb(snd_urb)` fails, or `cxacru_start_wait_urb(snd_urb)` fails. Either way, `rcv_urb` is still active when the `fail:` label is reached, thus `usb_kill_urb` is needed.
The important thing is that `rcv_urb` is *not* cleaned up if the submit or wait operation of the *write* URB fails. This leaves it in an active state, causing the busy error on the next call to the function. This covers both the submission and timeout scenarios of the write URB. If the read URB times out, the `cxacru_timeout_kill` will be responsible for unlinking it, and the error code path will be entered. So only the failure cases for the write URB are important.
|
| 27/2 |
2026/07/31 07:17 |
tool |
codesearch-definition-source |
0m
Args: map[Name:cxacru_start_wait_urb]
Results: map[SourceCode: 590: static int cxacru_start_wait_urb(struct urb *urb, struct completion *done,
591: int *actual_length)
592: {
593: struct cxacru_timer timer = {
594: .urb = urb,
595: };
596:
597: timer_setup_on_stack(&timer.timer, cxacru_timeout_kill, 0);
598: mod_timer(&timer.timer, jiffies + msecs_to_jiffies(CMD_TIMEOUT));
599: wait_for_completion(done);
600: timer_delete_sync(&timer.timer);
601: timer_destroy_on_stack(&timer.timer);
602:
603: if (actual_length)
604: *actual_length = urb->actual_length;
605: return urb->status; /* must read status after completion */
606: }
SourceFile:drivers/usb/atm/cxacru.c]
|
| 28/2 |
2026/07/31 07:17 |
llm |
debugger |
0m
Model:
Tokens:
input: 30134
output: 25
thoughts: 1184
Thoughts: **Analyzing URB Completion and Error Handling**
Okay, let's break this down. My understanding is that `wait_for_completion(done)` is crucial here, as it's the mechanism that waits for a URB to complete. If it times out, a timeout function, `cxacru_timeout_kill`, is triggered which calls `usb_unlink_urb`. This unlinks the URB, causing it to complete with `-ENOENT` or `-ECONNRESET`, which then triggers the completion handler and the subsequent `complete(done)` call, which returns to the waiting function.
Now, I see a potential issue: if the `snd_urb` fails during `cxacru_start_wait_urb`, the `rcv_urb` is never waited on, and therefore, never unlinked. This leaves the `rcv_urb` hanging. The fix seems straightforward: we need to kill the `rcv_urb` in the `fail:` path, right after `snd_urb` fails, to make sure it is not left active.
But then I thought, if `rcv_urb` itself fails during `cxacru_start_wait_urb` it is unlinked by the timer, or completed with an error, so the `usb_kill_urb` call would be a no-op, although safe. Likewise, if `cxacru_cm` succeeds, the `rcv_urb` would have completed successfully, again making the `usb_kill_urb` call safe but unnecessary. The only place we *need* to kill `rcv_urb` is if we are aborting early.
Let me go through the `cxacru_cm` error handling. It looks like it would make sense to add `usb_kill_urb(instance->rcv_urb);` at the `fail:` label. But I want to make sure I am covering all the scenarios.
Let's look at the failure cases to be certain:
* If we jump to `fail:` because `usb_submit_urb(instance->rcv_urb)` failed, then `rcv_urb` is not active, so `usb_kill_urb` is a no-op.
* If we jump to `fail:` because `usb_submit_urb(instance->snd_urb)` failed, `rcv_urb` is active, so `usb_kill_urb` will kill it and wait for it to complete. This is exactly what we want.
* If we jump to `fail:` because `cxacru_start_wait_urb(instance->snd_urb)` failed, `rcv_urb` is active, so `usb_kill_urb` will kill it.
* If we jump to `fail:` because `cxacru_start_wait_urb(instance->rcv_urb)` failed, `rcv_urb` is already complete (with error), so `usb_kill_urb` is a no-op.
* If we jump to `fail:` because of invalid response length or wrong cm, `rcv_urb` is already complete, so `usb_kill_urb` is a no-op.
One last thing, is it safe to call `usb_kill_urb` while holding `instance->cm_serialize`? Good, `usb_kill_urb` just waits for the URB to complete. The completion handler `cxacru_blocking_completion` does not take this mutex.
So, in conclusion, adding `usb_kill_urb(instance->rcv_urb);` at the `fail:` label seems like the right solution, as it will cover all the error cases and safely handle the `rcv_urb` if the process aborts early.
|
| 29/2 |
2026/07/31 07:17 |
tool |
codesearch-definition-source |
0m
Args: map[Name:cxacru_blocking_completion]
Results: map[SourceCode: 572: /* the following three functions are stolen from drivers/usb/core/message.c */
573: static void cxacru_blocking_completion(struct urb *urb)
574: {
575: complete(urb->context);
576: }
SourceFile:drivers/usb/atm/cxacru.c]
|
| 30/2 |
2026/07/31 07:17 |
llm |
debugger |
0m
Model:
Tokens:
input: 32261
output: 27
thoughts: 1165
Thoughts: **Analyzing URB Completion and Termination in the `cxacru` Context**
Okay, let's break this down systematically. I see that `cxacru_blocking_completion` just calls `complete(urb->context)`. So, calling `usb_kill_urb` while the mutex is held should be perfectly safe, that part's straightforward.
My primary concern revolves around the potential for URBs remaining active in error scenarios, particularly `rcv_urb` and `snd_urb`. If `usb_kill_urb(instance->rcv_urb)` is called at the `fail:` label, I need to be absolutely certain of the state of both URBs.
Initially, I considered the scenario where `snd_urb` might also be active, especially if `cxacru_start_wait_urb(instance->snd_urb)` fails. However, the logic clearly indicates that a timeout in `cxacru_start_wait_urb(instance->snd_urb)` results in it being unlinked and completed. Failures during `usb_submit_urb(instance->snd_urb)` or `usb_submit_urb(instance->rcv_urb)` will always leave these URBs in the inactive state.
Then, there's the question of `rcv_urb`'s behavior within `usb_kill_urb` given its completion handler. My conclusion is that because we hold the `cm_serialize` mutex there's no way another thread can get in the way of `rcv_done`, so there's no race condition.
I had a moment of confusion when re-examining `fail:`, but it's just the label for the unlock. Adding `usb_kill_urb(instance->rcv_urb);` before `fail:` is a fine way to kill the URB on error or success, so that's good. And calling `usb_kill_urb` on an already completed URB is a safe, no-op. But it's better to avoid the extra call on success. But if we only call it if `ret < 0`, that makes sure we don't try to kill it if the URB hasn't been submitted yet.
I think the safest approach would be adding:
```c
if (ret < 0)
usb_kill_urb(instance->rcv_urb);
```
before `mutex_unlock(&instance->cm_serialize);`.
This handles failures at several points: submission of either URB, and `cxacru_start_wait_urb` for both. This will ensure that `rcv_urb` is killed only on error. The URB will be inactive due to timeout, or another error.
Finally, I confirmed that `snd_urb` is also always properly handled due to the logic in `cxacru_start_wait_urb`. The use of `wait_for_completion` (not `wait_for_completion_interruptible`) prevents any signal-based interruptions that could leave it in an indeterminate state.
|
| 31/2 |
2026/07/31 07:18 |
tool |
codesearch-find-references |
0m
Args: map[Name:cxacru_start_wait_urb]
Results: map[References:[map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:cxacru_cm SourceFile:drivers/usb/atm/cxacru.c SourceLine:657] map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:cxacru_cm SourceFile:drivers/usb/atm/cxacru.c SourceLine:664]] TruncatedOutput:false]
|
| 32/2 |
2026/07/31 07:18 |
llm |
debugger |
0m
Model:
Tokens:
input: 34231
output: 27
thoughts: 1773
Thoughts: **Analyzing USB URB Management in `cxacru_cm`**
Okay, let's break this down. My primary concern is ensuring the safe killing and unlinking of USB URBs, specifically within the `cxacru_cm` function. The code seems to be running in process context, as it's called from a workqueue or `cxacru_atm_start`, which traces back to `usbatm_atm_init` and `usbatm_usb_probe`. This means `usb_kill_urb` can be used, which is good. There's also a mutex, which covers any potential sleeps in `usb_kill_urb`.
The core issue appears to be around how `cxacru_cm` handles errors and manages the `rcv_urb` and `snd_urb` URBs. Looking at the code:
If `ret < 0` after `cxacru_start_wait_urb`, a `fail:` label is reached, with a subsequent `mutex_unlock`. My initial thought is to kill `rcv_urb` in this case. However, let's explore all possible scenarios:
* If `usb_submit_urb(instance->rcv_urb)` fails, then `rcv_urb` wasn't actually submitted and so calling `usb_kill_urb` on it would just return. So, it's safe.
* If `usb_submit_urb(instance->snd_urb)` fails, then `rcv_urb` has been submitted and active. So, this warrants killing of `rcv_urb`.
* If `cxacru_start_wait_urb(instance->snd_urb)` fails, `rcv_urb` will have been submitted, so `usb_kill_urb` is necessary.
* If `cxacru_start_wait_urb(instance->rcv_urb)` times out or the completion handler fails, `usb_kill_urb` will kill the urb.
* If `ret < 0` for any reason, `usb_kill_urb` is safe to run.
* If `ret >= 0`, then `usb_kill_urb` is *not* called, and `rcv_urb` completed successfully and is no longer active.
Now, I need to make sure that the `snd_urb` doesn't become active. I identified that if `cxacru_start_wait_urb(instance->snd_urb)` times out, `cxacru_timeout_kill` is called, which calls `usb_unlink_urb` on the `snd_urb`. This is asynchronous, but the `wait_for_completion` after it ensures that the completion handler has completed. There is also `timer_delete_sync(&timer.timer)`, which will handle any active URBs. So, `snd_urb` is never left active.
The problem, as I see it, is that the current `fail` logic fails to kill the `rcv_urb` in certain error conditions.
Analyzing a specific crash log provides evidence:
```
cxacru 1-1:1.0: send of cm 0x84 failed (-104)
ATM dev 0: cxacru_atm_start: CHIP_ADSL_LINE_START returned -104
------------[ cut here ]------------
URB ffff88812658d200 submitted while active
WARNING: drivers/usb/core/urb.c:379 at usb_submit_urb+0x79/0x18b0 drivers/usb/core/urb.c:379, CPU#1: kworker/1:1/5258
```
The error `-104` (ECONNRESET) means the `snd_urb` was unlinked or the device was disconnected *during* a `cxacru_start_wait_urb` call. This directly ties to `cxacru_cm` jumping to `fail:` without killing the `rcv_urb`! It appears to leave `rcv_urb` active. The subsequent call to `cxacru_cm` then re-submits an already active URB, triggering the warning.
So, in conclusion, the code requires modification to call `usb_kill_urb(instance->rcv_urb)` when returning from `cxacru_cm` and *any* error condition to prevent this URB submitted while active error.
|
| 33/2 |
2026/07/31 07:18 |
tool |
codesearch-definition-source |
0m
Error:
Args: map[Name:CM_REQUEST_CARD_GET_STATUS]
Results: map[SourceCode: SourceFile:]
|
| 34/2 |
2026/07/31 07:18 |
llm |
debugger |
0m
Model:
Tokens:
input: 37034
output: 25
thoughts: 13
Thoughts: Okay, here's my interpretation of that thought process, assuming I'm deeply familiar with the relevant technical domain and context.
**Checking `cxacru_cm_request`**
Alright, let's dive into this. "Let's check `cxacru_cm_request`." Hmm, that's a very specific identifier. Clearly, I'm thinking about a process or a data structure named `cxacru_cm_request`. Based on the naming convention, it suggests this might be related to a request, likely something central management (CM) related and probably part of an ACru system or module.
The thought implies I've either been alerted to something, perhaps a performance issue, a bug, or an unusual pattern, that warrants immediate inspection of this particular piece. Or perhaps I'm in the process of debugging a workflow.
It tells me I know *where* to look - I'm already aware of this specific entity and its role within the larger system. It also means I am confident that examining this component will give me some insight into the problem, and I'm heading in the right direction. It's a targeted check, not a generic search. The fact that the thought is so concise, I'm probably pretty sure I'll get to the heart of the matter quickly. Let's see what's in there.
|
| 35/2 |
2026/07/31 07:18 |
tool |
codesearch-definition-source |
0m
Args: map[Name:cxacru_cm_request]
Results: map[SourceCode: 69: /* commands for interaction with the modem through the control channel once
70: * firmware is loaded */
71: enum cxacru_cm_request {
72: CM_REQUEST_UNDEFINED = 0x80,
73: CM_REQUEST_TEST,
74: CM_REQUEST_CHIP_GET_MAC_ADDRESS,
75: CM_REQUEST_CHIP_GET_DP_VERSIONS,
76: CM_REQUEST_CHIP_ADSL_LINE_START,
77: CM_REQUEST_CHIP_ADSL_LINE_STOP,
78: CM_REQUEST_CHIP_ADSL_LINE_GET_STATUS,
79: CM_REQUEST_CHIP_ADSL_LINE_GET_SPEED,
80: CM_REQUEST_CARD_INFO_GET,
81: CM_REQUEST_CARD_DATA_GET,
82: CM_REQUEST_CARD_DATA_SET,
83: CM_REQUEST_COMMAND_HW_IO,
84: CM_REQUEST_INTERFACE_HW_IO,
85: CM_REQUEST_CARD_SERIAL_DATA_PATH_GET,
86: CM_REQUEST_CARD_SERIAL_DATA_PATH_SET,
87: CM_REQUEST_CARD_CONTROLLER_VERSION_GET,
88: CM_REQUEST_CARD_GET_STATUS,
89: CM_REQUEST_CARD_GET_MAC_ADDRESS,
90: CM_REQUEST_CARD_GET_DATA_LINK_STATUS,
91: CM_REQUEST_MAX,
92: };
SourceFile:drivers/usb/atm/cxacru.c]
|
| 36/2 |
2026/07/31 07:18 |
llm |
debugger |
0m
Model:
Tokens:
input: 37806
output: 25
thoughts: 551
Thoughts: **Analyzing a USB ATM Driver Crash**
Okay, let's break this down. I see a `CM_REQUEST_UNDEFINED` defined as `0x80`, and other requests defined as well, with `CM_REQUEST_CHIP_ADSL_LINE_START` being `0x84`. I'm focusing on that one now. The log indicates a failed `send of cm 0x84` with an error code of `-104`. This failure propagates up, as expected, leading to a `-104` return from `cxacru_atm_start`. Ultimately, `usbatm_atm_init` fails, which then leads to `usbatm_usb_probe` failing.
Now, if `usbatm_usb_probe` fails, the standard flow should include cleanup and a return. But here's where it gets interesting β the system crashes *back* in `cxacru_cm`. That's unexpected. Let's look at the call trace: `cxacru_cm`, `cxacru_cm_get_array`, `cxacru_poll_status`, `cxacru_atm_start`, `usbatm_atm_init`, and finally `usbatm_usb_probe` and `cxacru_usb_probe`.
Aha! The crash occurs within `cxacru_poll_status`, which is called from within `cxacru_atm_start`. So the initial failure to start the ADSL line is masking something more fundamental. Time to examine the code in `cxacru_atm_start` and see what's going on there. I'm focusing on the interaction between `cxacru_cm`, `cxacru_poll_status`, and the error handling within `cxacru_atm_start` now, specifically the conditions that might lead to a crash after a seemingly handled failure.
|
| 37/2 |
2026/07/31 07:18 |
tool |
codesearch-definition-source |
0m
Args: map[Name:cxacru_atm_start]
Results: map[SourceCode: 769: static int cxacru_atm_start(struct usbatm_data *usbatm_instance,
770: struct atm_dev *atm_dev)
771: {
772: struct cxacru_data *instance = usbatm_instance->driver_data;
773: struct usb_interface *intf = usbatm_instance->usb_intf;
774: int ret;
775: int start_polling = 1;
776:
777: dev_dbg(&intf->dev, "%s\n", __func__);
778:
779: /* Read MAC address */
780: ret = cxacru_cm(instance, CM_REQUEST_CARD_GET_MAC_ADDRESS, NULL, 0,
781: atm_dev->esi, sizeof(atm_dev->esi));
782: if (ret < 0) {
783: atm_err(usbatm_instance, "cxacru_atm_start: CARD_GET_MAC_ADDRESS returned %d\n", ret);
784: return ret;
785: }
786:
787: /* start ADSL */
788: mutex_lock(&instance->adsl_state_serialize);
789: ret = cxacru_cm(instance, CM_REQUEST_CHIP_ADSL_LINE_START, NULL, 0, NULL, 0);
790: if (ret < 0)
791: atm_err(usbatm_instance, "cxacru_atm_start: CHIP_ADSL_LINE_START returned %d\n", ret);
792:
793: /* Start status polling */
794: mutex_lock(&instance->poll_state_serialize);
795: switch (instance->poll_state) {
796: case CXPOLL_STOPPED:
797: /* start polling */
798: instance->poll_state = CXPOLL_POLLING;
799: break;
800:
801: case CXPOLL_STOPPING:
802: /* abort stop request */
803: instance->poll_state = CXPOLL_POLLING;
804: fallthrough;
805: case CXPOLL_POLLING:
806: case CXPOLL_SHUTDOWN:
807: /* don't start polling */
808: start_polling = 0;
809: }
810: mutex_unlock(&instance->poll_state_serialize);
811: mutex_unlock(&instance->adsl_state_serialize);
812:
813: if (start_polling)
814: cxacru_poll_status(&instance->poll_work.work);
815: return 0;
816: }
SourceFile:drivers/usb/atm/cxacru.c]
|
| 38/2 |
2026/07/31 07:18 |
llm |
debugger |
0m
Model:
Tokens:
input: 39615
output: 23
thoughts: 1555
Thoughts: **Root Cause Analysis and Proposed Fix for USB ATM Driver Crash**
Okay, let's break this down. It seems the `cxacru_atm_start` function calls `cxacru_cm` to request a chip ADSL line start, but it doesn't properly handle the error if that initial communication fails. Specifically, if `CM_REQUEST_CHIP_ADSL_LINE_START` fails, `cxacru_atm_start` prints an error but continues execution. This is a problem. It moves on to polling status, which in turn calls `cxacru_cm` again, but the crucial point is that the receive URB (`rcv_urb`) was left active from that initial failed `CHIP_ADSL_LINE_START` call. The next call to `cxacru_cm` then tries to resubmit this active URB, leading to the "URB submitted while active" warning and a potential crash.
The logs perfectly mirror this sequence. The initial CM request fails with error -104, the driver logs the error, *and then* the subsequent status polling attempts, now resubmitting the URB that's still active, causes the crash.
So, the core problem is that `cxacru_cm` is not properly cleaning up the receive URB when it encounters an error submitting the command or the URB fails to complete. Although `cxacru_unbind` cleans up the URB, calls to `cxacru_cm` from other places will leave the URB active if there's an error.
The first, immediate solution that jumps to mind is to ensure that `cxacru_cm` *always* kills the `rcv_urb` if there's an error. Even if we're not unbinding the device, the general principle is to clean up resources after any failure, because this could cause more problems later. So that means that we need to add a `usb_kill_urb(instance->rcv_urb)` call.
However, we need to ensure this is safe. `usb_kill_urb` itself is safe to call, checking the URB status. We want to place this call in the error handling section of `cxacru_cm`. I can see there's a `goto fail;` label used for error handling. So, the fix looks something like this (insert this in the `fail:` section):
```c
fail:
if (ret < 0)
usb_kill_urb(instance->rcv_urb);
mutex_unlock(&instance->cm_serialize);
```
Let's carefully verify the safety of this change. It looks like it is safe.
The main thing is to confirm `usb_kill_urb` will not be called when it doesn't need to be.
If submission or the `cxacru_start_wait_urb` fails then `rcv_urb` will still be active.
If `actlen % CMD_PACKET_SIZE` fails, then `rcv_urb` completed successfully and is not active. This will cause `usb_kill_urb` to be a no-op. If `ret >= 0`, `usb_kill_urb` will also be a no-op.
The current implementation of `cxacru_cm` will return to the `fail:` label, after a successful operation, so this `if` statement will prevent the function call overhead.
This looks like a robust and correct solution. The revised `cxacru_cm` now cleans up the `rcv_urb` on any error condition, preventing the "URB submitted while active" warning and the potential crash. We're also addressing the underlying resource management issue, ensuring the driver is more resilient to communication failures. This is a *must-fix*.
|
| 39/2 |
2026/07/31 07:19 |
tool |
codesearch-definition-source |
0m
Args:
Results: map[SourceCode: 676: /**
677: * usb_kill_urb - cancel a transfer request and wait for it to finish
678: * @urb: pointer to URB describing a previously submitted request,
679: * may be NULL
680: *
681: * This routine cancels an in-progress request. It is guaranteed that
682: * upon return all completion handlers will have finished and the URB
683: * will be totally idle and available for reuse. These features make
684: * this an ideal way to stop I/O in a disconnect() callback or close()
685: * function. If the request has not already finished or been unlinked
686: * the completion handler will see urb->status == -ENOENT.
687: *
688: * While the routine is running, attempts to resubmit the URB will fail
689: * with error -EPERM. Thus even if the URB's completion handler always
690: * tries to resubmit, it will not succeed and the URB will become idle.
691: *
692: * The URB must not be deallocated while this routine is running. In
693: * particular, when a driver calls this routine, it must insure that the
694: * completion handler cannot deallocate the URB.
695: *
696: * This routine may not be used in an interrupt context (such as a bottom
697: * half or a completion handler), or when holding a spinlock, or in other
698: * situations where the caller can't schedule().
699: *
700: * This routine should not be called by a driver after its disconnect
701: * method has returned.
702: */
703: void usb_kill_urb(struct urb *urb)
704: {
705: might_sleep();
706: if (!(urb && urb->dev && urb->ep))
707: return;
708: atomic_inc(&urb->reject);
709: /*
710: * Order the write of urb->reject above before the read
711: * of urb->use_count below. Pairs with the barriers in
712: * __usb_hcd_giveback_urb() and usb_hcd_submit_urb().
713: */
714: smp_mb__after_atomic();
715:
716: usb_hcd_unlink_urb(urb, -ENOENT);
717: wait_event(usb_kill_urb_queue, atomic_read(&urb->use_count) == 0);
718:
719: atomic_dec(&urb->reject);
720: }
SourceFile:drivers/usb/core/urb.c]
|
| 40/2 |
2026/07/31 07:19 |
llm |
debugger |
0m
Model:
Tokens:
input: 42797
output: 25
thoughts: 2213
Thoughts: **Analysis of USB URB Handling in cxacru Driver**
Okay, let's break this down. First, the question was about the safety of `usb_kill_urb`, even if the URB isn't active. The conclusion here is that it's safe. It handles the inactive case gracefully by incrementing `reject`, calling `usb_hcd_unlink_urb` (which returns an error), waiting for `use_count == 0` (which is already true), and decrementing `reject`. The optimization with `if (ret < 0)` is good.
Now, what if `usb_kill_urb` is called while the receive URB (`rcv_urb`) *is* active? That's the core concern. The logic shows it will unlink it, wait for `use_count == 0`, and the completion handler will call `complete(&instance->rcv_done)`. This also seems safe. I need to be sure the completion is handled correctly.
What if the `cxacru_start_wait_urb` fails due to a timeout? Okay, so if the send URB (`snd_urb`) timed out, the timer will unlink it, `cxacru_cm` jumps to the `fail:` label, and `usb_kill_urb(instance->rcv_urb)` is called. Then, the `cm_serialize` mutex is unlocked. This *looks* correct.
Next, I need to check for any other potential issues. What if the requested transfer size is too large in `cxacru_cm`? The code checks for this: `wbuflen > PAGE_SIZE || rbuflen > PAGE_SIZE`. If this is true, it goes to `err:`, bypassing the `fail:` logic. Since the `rcv_urb` hasn't been submitted yet, it's not active and there's no issue here.
What if `usb_submit_urb(instance->rcv_urb)` fails? It jumps to `fail:`. Since it failed to submit, `rcv_urb` is not active and `usb_kill_urb` returns immediately. Correct.
What if `usb_submit_urb(instance->snd_urb)` fails? Okay, it goes to `fail:`. This time, `rcv_urb` *is* likely active. `usb_kill_urb` will unlink it and wait for completion. Also correct.
If `cxacru_start_wait_urb(instance->snd_urb)` fails, it jumps to `fail:` and the code executes the same safe sequence as above. The `rcv_urb` is active, it gets killed, and the mutex is unlocked. Still looks good.
If `cxacru_start_wait_urb(instance->rcv_urb)` fails (likely a timeout), again, the logic executes as intended, where `rcv_urb` is already unlinked or completed. `usb_kill_urb` does the right thing, and the program flow is safe.
What if the receive length (`actlen`) is invalid? It goes to `fail:`, and once again, the current analysis applies, with `rcv_urb` being unlinked or complete. Also correct.
So, the fix is robust, `fail:` label calls `usb_kill_urb(instance->rcv_urb)` if there's an error, and unlocks `instance->cm_serialize`.
Now, let's think about other URBs and their states. Is `snd_urb` ever left active? No, `usb_submit_urb` failures, or the timer unlinking it, should ensure the URB is killed. The check also ensures that `wait_for_completion` is uninterruptible, so the `snd_urb` is never left active.
What about concurrency? `cxacru_cm` is protected by `mutex_lock(&instance->cm_serialize)`, which blocks any concurrent access. So that's safe.
What about `cxacru_unbind` during `cxacru_cm`? That's a critical point. `cxacru_unbind` will call `usb_kill_urb` for both URBs. This should cause the URBs to complete with `-ENOENT`. Then `cxacru_start_wait_urb` will return `-ENOENT`. This also should mean that we will arrive to `fail:`, which means the same clean shutdown, and release of the mutex. However, `cxacru_unbind` frees the URBs, but *doesn't* take the `cm_serialize` mutex. That's a potential race condition!
Is this actually possible? `cxacru_cm` comes from a workqueue in `cx
|
| 41/2 |
2026/07/31 07:19 |
tool |
codesearch-definition-source |
0m
Args: map[Name:usbatm_usb_disconnect]
Results: map[SourceCode:1207: void usbatm_usb_disconnect(struct usb_interface *intf)
1208: {
1209: struct device *dev = &intf->dev;
1210: struct usbatm_data *instance = usb_get_intfdata(intf);
1211: struct usbatm_vcc_data *vcc_data;
1212: int i;
1213:
1214: if (!instance) {
1215: dev_dbg(dev, "%s: NULL instance!\n", __func__);
1216: return;
1217: }
1218:
1219: usb_set_intfdata(intf, NULL);
1220:
1221: mutex_lock(&instance->serialize);
1222: instance->disconnected = 1;
1223: if (instance->thread != NULL)
1224: send_sig(SIGTERM, instance->thread, 1);
1225: mutex_unlock(&instance->serialize);
1226:
1227: wait_for_completion(&instance->thread_exited);
1228:
1229: mutex_lock(&instance->serialize);
1230: list_for_each_entry(vcc_data, &instance->vcc_list, list)
1231: vcc_release_async(vcc_data->vcc, -EPIPE);
1232: mutex_unlock(&instance->serialize);
1233:
1234: tasklet_disable(&instance->rx_channel.tasklet);
1235: tasklet_disable(&instance->tx_channel.tasklet);
1236:
1237: for (i = 0; i < num_rcv_urbs + num_snd_urbs; i++)
1238: usb_kill_urb(instance->urbs[i]);
1239:
1240: timer_delete_sync(&instance->rx_channel.delay);
1241: timer_delete_sync(&instance->tx_channel.delay);
1242:
1243: /* turn usbatm_[rt]x_process into something close to a no-op */
1244: /* no need to take the spinlock */
1245: INIT_LIST_HEAD(&instance->rx_channel.list);
1246: INIT_LIST_HEAD(&instance->tx_channel.list);
1247:
1248: tasklet_enable(&instance->rx_channel.tasklet);
1249: tasklet_enable(&instance->tx_channel.tasklet);
1250:
1251: if (instance->atm_dev && instance->driver->atm_stop)
1252: instance->driver->atm_stop(instance, instance->atm_dev);
1253:
1254: if (instance->driver->unbind)
1255: instance->driver->unbind(instance, intf);
1256:
1257: instance->driver_data = NULL;
1258:
1259: for (i = 0; i < num_rcv_urbs + num_snd_urbs; i++) {
1260: kfree(instance->urbs[i]->transfer_buffer);
1261: usb_free_urb(instance->urbs[i]);
1262: }
1263:
1264: kfree(instance->cell_buf);
1265:
1266: /* ATM finalize */
1267: if (instance->atm_dev) {
1268: atm_dev_deregister(instance->atm_dev);
1269: instance->atm_dev = NULL;
1270: }
1271:
1272: usbatm_put_instance(instance); /* taken in usbatm_usb_probe */
1273: }
SourceFile:drivers/usb/atm/usbatm.c]
|
| 42/2 |
2026/07/31 07:19 |
llm |
debugger |
0m
Model:
Tokens:
input: 47136
output: 24
thoughts: 110
Thoughts: **Dissecting the USB Disconnect Path**
Okay, so I'm tracing the disconnect path within the USB ATM driver. Specifically, `usbatm_usb_disconnect` is calling `instance->driver->unbind(instance, intf)`, which I know maps directly to `cxacru_unbind` in this case. That makes sense, standard unbinding process.
However, I'm a little concerned. Before the unbind, it's calling `instance->driver->atm_stop(instance, instance->atm_dev)`. The thing is, `cxacru` doesn't actually define or implement an `atm_stop` function! That's a potential area for a bug, or perhaps some unexpected side effect. I need to figure out what that call is doing, even if it's a no-op.
Then I get to thinking about sysfs. I'm trying to remember exactly *where* the sysfs attributes for this device are registered. Are they attached to `instance->usb_intf->dev`, representing the USB interface itself, or are they under `instance->atm_dev` which represents the ATM device within the USB device? I'm not entirely sure, and that's important for understanding how the device presents its state to the user. I'll need to double check the sysfs creation code to get the answer.
|
| 43/2 |
2026/07/31 07:19 |
tool |
codesearch-find-references |
0m
Args: map[Name:adsl_config_store]
Results: map[References:[map[ReferenceKind:takes-address-of ReferencingEntityKind:global_variable ReferencingEntityName:dev_attr_adsl_config SourceFile:drivers/usb/atm/cxacru.c SourceLine:539] map[ReferenceKind:takes-address-of ReferencingEntityKind:global_variable ReferencingEntityName:dev_attr_adsl_config SourceFile:drivers/usb/atm/cxacru.c SourceLine:539] map[ReferenceKind:takes-address-of ReferencingEntityKind:global_variable ReferencingEntityName:dev_attr_adsl_config SourceFile:drivers/usb/atm/cxacru.c SourceLine:539]] TruncatedOutput:false]
|
| 44/2 |
2026/07/31 07:19 |
llm |
debugger |
0m
Model:
Tokens:
input: 47766
output: 26
thoughts: 14
Thoughts: Okay, let's dive into this. Here's my take on those thoughts, as if they're my own:
**Analyzing the Configuration Variable: `dev_attr_adsl_config`**
Alright, let's take a closer look at `dev_attr_adsl_config`. I'm immediately curious about what this configuration variable specifically defines. Is it related to the device attributes, possibly for an ADSL connection, as the name hints at? My experience tells me that such configurations can involve a multitude of parameters - MTU size, VPI/VCI values, encapsulation methods (like PPPoE or PPPoA), authentication credentials, and even QoS settings, to name a few.
I need to understand its scope. Is this a system-wide setting, or is it specific to a particular network interface or device instance? Are there other related variables or structures that this config links to? Parsing the associated code, if available, would be the first order of business to figure out how the software actually processes this configuration.
Furthermore, how is the data structure defined? Is it a simple string, an integer, a boolean, or a more complex structure? Are there any validation routines or error handling mechanisms in place for this particular configuration element? Knowing this is paramount, because a malformed setting can cause network instability or complete service failure.
Essentially, I'm thinking about the implications of this variable. Is it an important parameter, as the name makes me believe it is? Is it a key to understanding device connectivity, or just a small piece of the puzzle? What is the impact of changing this particular variable? It will require some thorough examination.
|
| 45/2 |
2026/07/31 07:19 |
tool |
codesearch-find-references |
0m
Args: map[Name:dev_attr_adsl_config]
Results: map[References:<nil> TruncatedOutput:false]
|
| 46/2 |
2026/07/31 07:19 |
llm |
debugger |
0m
Model:
Tokens:
input: 48169
output: 26
thoughts: 11
Thoughts: Okay, I'm ready to summarize my thought process. Here's how I'm approaching it:
**Thinking Critically About Usage**
Okay, first things first, before I dive into any conclusions or analyses, I need to understand the context. Where exactly is this being used? Knowing the specific application β the field, the system, the project β is absolutely crucial. Without that foundation, any interpretation or assessment is essentially meaningless. I need to pinpoint the application. Then I can make sense of how it functions. That's the baseline.
|
| 47/2 |
2026/07/31 07:19 |
tool |
codesearch-definition-source |
0m
Args: map[Name:dev_attr_adsl_config]
Results: map[SourceCode: 539: CXACRU_ALL_FILES(INIT);
SourceFile:drivers/usb/atm/cxacru.c]
|
| 48/2 |
2026/07/31 07:19 |
llm |
debugger |
0m
Model:
Tokens:
input: 48371
output: 25
thoughts: 10
Thoughts: Here's my attempt at summarizing the thought process, tailored for an expert audience:
**Macro-Generated Code - Initial Assessment**
Okay, so I'm looking at this code, and the first thing that jumps out is the structure. It's got that unmistakable fingerprint of a macro-generated program. The repetitive patterns, the potential for abstracted logic, it all screams "macro." Now, the implications are immediate. We're dealing with an abstraction layer. I need to figure out *what* abstraction layer, which usually requires tracing back the preprocessor directives or whatever is generating this stuff. This also means understanding the *purpose* of the macro. Is it for code generation, template instantiation, or something else entirely? Depending on that, my analysis changes quite a bit. My immediate task becomes identifying the macro's definition and its expansion. This will be key to understanding the underlying logic and potential vulnerabilities, since it all relies on the structure set out by the original macro code. I'll need to know the development environment to understand any possible preprocessor directives used.
|
| 49/2 |
2026/07/31 07:19 |
tool |
codesearch-definition-source |
0m
Error:
Args: map[Name:CXACRU_ALL_FILES]
Results: map[SourceCode: SourceFile:]
|
| 50/2 |
2026/07/31 07:19 |
llm |
debugger |
0m
Model:
Tokens:
input: 48648
output: 21
thoughts: 14
Thoughts: Here's my attempt at summarizing the thought process, tailored for an expert audience:
**Grep'ing for the Needle in the Haystack**
Okay, so I'm thinking about how to approach this... My first instinct is to zero in on the obvious: `CXACRU_ALL_FILES`. It's likely a defining variable, a constant, a macro, something that encapsulates the set of files we're dealing with. If it's used with that name consistently, which I'd expect, I should be able to hunt it down pretty quickly with a simple `grep`. I'm mentally making a mental note to refine the `grep` search if I don't get the correct results on the first attempt, I'll need to think about flags and context. I'll need to figure out what type of tool I want to search with: `grep`, `ag`, or something more specialized, depending on the scale and complexity of the codebase. I might need to specify the file types I'm interested in too, to avoid sifting through irrelevant binary data. Hopefully, this variable is well-defined, and the surrounding code will tell me what it's all about.
|
| 51/2 |
2026/07/31 07:19 |
tool |
grepper |
0m
Args: map[Expression:CXACRU_ALL_FILES]
Results: map[Output:drivers/usb/atm/cxacru.c=435=static ssize_t adsl_config_store(struct device *dev,
--
drivers/usb/atm/cxacru.c-501-/*
drivers/usb/atm/cxacru.c:502: * All device attributes are included in CXACRU_ALL_FILES
drivers/usb/atm/cxacru.c-503- * so that the same list can be used multiple times:
--
drivers/usb/atm/cxacru.c-508- * With the last two being defined as needed in the functions
drivers/usb/atm/cxacru.c:509: * they are used in before calling CXACRU_ALL_FILES()
drivers/usb/atm/cxacru.c-510- */
drivers/usb/atm/cxacru.c:511:#define CXACRU_ALL_FILES(_action) \
drivers/usb/atm/cxacru.c-512-CXACRU_ATTR_##_action(CXINF_DOWNSTREAM_RATE, u32, downstream_rate); \
--
drivers/usb/atm/cxacru.c=537=CXACRU_SET_##_action( adsl_config);
drivers/usb/atm/cxacru.c-538-
drivers/usb/atm/cxacru.c:539:CXACRU_ALL_FILES(INIT);
drivers/usb/atm/cxacru.c-540-
]
|
| 52/2 |
2026/07/31 07:20 |
llm |
debugger |
0m
Model:
Tokens:
input: 49312
output: 21
thoughts: 17
Thoughts: Here's a summary of my thought process:
**Hunting Down the Usage of `CXACRU_ALL_FILES`**
Okay, so I need to figure out where `CXACRU_ALL_FILES` is actually being used in this codebase. I'm approaching this systematically. I'll need to use some search tools to track down all instances of this. Probably a grep or a similar command-line utility will be the most efficient way to start. I'll need to consider how the code is structured - are we dealing with a monolithic application or something modular? Does the search need to be case-sensitive, or are we dealing with consistent naming conventions that make it safe to ignore casing? I'll need to keep in mind possible variations, like if it's used with prefixes or suffixes. After locating all references, I'll analyze each instance contextually. I'll note the exact location, the surrounding code, and I'll consider what's happening *around* the usage of the variable. I'll be looking for clues about its purpose, what data it's holding, and how that data is being processed, modified, or ultimately used. That's the first step.
|
| 53/2 |
2026/07/31 07:20 |
tool |
grepper |
0m
Args: map[Expression:CXACRU_ALL_FILES]
Results: map[Output:drivers/usb/atm/cxacru.c=435=static ssize_t adsl_config_store(struct device *dev,
--
drivers/usb/atm/cxacru.c-501-/*
drivers/usb/atm/cxacru.c:502: * All device attributes are included in CXACRU_ALL_FILES
drivers/usb/atm/cxacru.c-503- * so that the same list can be used multiple times:
--
drivers/usb/atm/cxacru.c-508- * With the last two being defined as needed in the functions
drivers/usb/atm/cxacru.c:509: * they are used in before calling CXACRU_ALL_FILES()
drivers/usb/atm/cxacru.c-510- */
drivers/usb/atm/cxacru.c:511:#define CXACRU_ALL_FILES(_action) \
drivers/usb/atm/cxacru.c-512-CXACRU_ATTR_##_action(CXINF_DOWNSTREAM_RATE, u32, downstream_rate); \
--
drivers/usb/atm/cxacru.c=537=CXACRU_SET_##_action( adsl_config);
drivers/usb/atm/cxacru.c-538-
drivers/usb/atm/cxacru.c:539:CXACRU_ALL_FILES(INIT);
drivers/usb/atm/cxacru.c-540-
]
|
| 54/2 |
2026/07/31 07:20 |
llm |
debugger |
0m
Model:
Tokens:
input: 49981
output: 22
thoughts: 23
Thoughts: Here's my thought process, as if I were considering this myself:
**Tracing Down a Code Dependency**
Okay, I need to figure out where this `CXACRU_ALL_FILES(CREATE)` macro, or something similar, is actually being utilized within this system. I know what that macro *should* do, but I need to see the context β how it's being invoked, what it's acting upon, and what other components are interacting with the results. Simply knowing the definition isn't enough; understanding the call stack and its relationship to other functions is the key to understanding its overall impact. I need to perform a code search. I'll need to check the codebase directly for this.
|
| 55/2 |
2026/07/31 07:20 |
tool |
grepper |
0m
Args: map[Expression:CXACRU_ALL_FILES\(]
Results: map[Output:drivers/usb/atm/cxacru.c=435=static ssize_t adsl_config_store(struct device *dev,
--
drivers/usb/atm/cxacru.c-508- * With the last two being defined as needed in the functions
drivers/usb/atm/cxacru.c:509: * they are used in before calling CXACRU_ALL_FILES()
drivers/usb/atm/cxacru.c-510- */
drivers/usb/atm/cxacru.c:511:#define CXACRU_ALL_FILES(_action) \
drivers/usb/atm/cxacru.c-512-CXACRU_ATTR_##_action(CXINF_DOWNSTREAM_RATE, u32, downstream_rate); \
--
drivers/usb/atm/cxacru.c=537=CXACRU_SET_##_action( adsl_config);
drivers/usb/atm/cxacru.c-538-
drivers/usb/atm/cxacru.c:539:CXACRU_ALL_FILES(INIT);
drivers/usb/atm/cxacru.c-540-
]
|
| 56/2 |
2026/07/31 07:20 |
llm |
debugger |
0m
Model:
Tokens:
input: 50474
output: 19
thoughts: 28
Thoughts: Here's my thought process, as if I were considering this myself:
**Investigating a Kernel Device Driver Implementation**
Okay, so I need to figure out how this specific driver is handling the sysfs interface, or perhaps is implementing its own device file creations. My initial instinct is to jump into the `cxacru.c` source file. Itβs the obvious starting point. I want to look for the calls to `sysfs_create_group`. That function call is key because it indicates that this module is registering a group of attributes to be exported to the userspace via sysfs, so that's where I can configure and expose driver functionality. Alternatively, I'll be searching for any occurrences of `device_create_file`. This function would point to a custom driver implementation that directly makes device files, rather than relying on the general framework. Knowing which method is used is essential for my analysis. I anticipate, that depending on the implementation, I can quickly gain insight by investigating these functions.
|
| 57/2 |
2026/07/31 07:20 |
tool |
grepper |
0m
Args: map[Expression:device_create_file]
Results: map[Output:
Full output is too long, showing 500 out of 2347 lines.
Use more precise expression if possible.
Documentation/driver-api/driver-model/device.rst=107=to remove the device attributes.
Documentation/driver-api/driver-model/device.rst-108-
Documentation/driver-api/driver-model/device.rst:109:Word of warning: While the kernel allows device_create_file() and
Documentation/driver-api/driver-model/device.rst-110-device_remove_file() to be called on a device at any time, userspace has
--
Documentation/driver-api/driver-model/device.rst=118=attributes for a device at driver probe time. If the device driver simply
Documentation/driver-api/driver-model/device.rst:119:calls device_create_file() on the device structure passed to it, then
Documentation/driver-api/driver-model/device.rst-120-userspace will never be notified of the new attributes.
--
Documentation/filesystems/sysfs.rst=90=For example, the driver model defines struct device_attribute like::
--
Documentation/filesystems/sysfs.rst-99-
Documentation/filesystems/sysfs.rst:100: int device_create_file(struct device *, const struct device_attribute *);
Documentation/filesystems/sysfs.rst-101- void device_remove_file(struct device *, const struct device_attribute *);
--
Documentation/filesystems/sysfs.rst=377=Creation/Removal::
Documentation/filesystems/sysfs.rst-378-
Documentation/filesystems/sysfs.rst:379: int device_create_file(struct device *dev, const struct device_attribute * attr);
Documentation/filesystems/sysfs.rst-380- void device_remove_file(struct device *dev, const struct device_attribute * attr);
--
Documentation/translations/zh_CN/filesystems/sysfs.txt=103=struct device_attribute {
--
Documentation/translations/zh_CN/filesystems/sysfs.txt-110-
Documentation/translations/zh_CN/filesystems/sysfs.txt:111:int device_create_file(struct device *, const struct device_attribute *);
Documentation/translations/zh_CN/filesystems/sysfs.txt-112-void device_remove_file(struct device *, const struct device_attribute *);
--
Documentation/translations/zh_CN/filesystems/sysfs.txt=318=DEVICE_ATTR(_name, _mode, _show, _store);
--
Documentation/translations/zh_CN/filesystems/sysfs.txt-321-
Documentation/translations/zh_CN/filesystems/sysfs.txt:322:int device_create_file(struct device *dev, const struct device_attribute * attr);
Documentation/translations/zh_CN/filesystems/sysfs.txt-323-void device_remove_file(struct device *dev, const struct device_attribute * attr);
--
Documentation/translations/zh_TW/filesystems/sysfs.txt=106=struct device_attribute {
--
Documentation/translations/zh_TW/filesystems/sysfs.txt-113-
Documentation/translations/zh_TW/filesystems/sysfs.txt:114:int device_create_file(struct device *, const struct device_attribute *);
Documentation/translations/zh_TW/filesystems/sysfs.txt-115-void device_remove_file(struct device *, const struct device_attribute *);
--
Documentation/translations/zh_TW/filesystems/sysfs.txt=321=DEVICE_ATTR(_name, _mode, _show, _store);
--
Documentation/translations/zh_TW/filesystems/sysfs.txt-324-
Documentation/translations/zh_TW/filesystems/sysfs.txt:325:int device_create_file(struct device *dev, const struct device_attribute * attr);
Documentation/translations/zh_TW/filesystems/sysfs.txt-326-void device_remove_file(struct device *dev, const struct device_attribute * attr);
--
arch/arm/mach-pxa/sharpsl_pm.c=822=static int sharpsl_pm_probe(struct platform_device *pdev)
--
arch/arm/mach-pxa/sharpsl_pm.c-874-
arch/arm/mach-pxa/sharpsl_pm.c:875: ret = device_create_file(&pdev->dev, &dev_attr_battery_percentage);
arch/arm/mach-pxa/sharpsl_pm.c:876: ret |= device_create_file(&pdev->dev, &dev_attr_battery_voltage);
arch/arm/mach-pxa/sharpsl_pm.c-877- if (ret != 0)
--
arch/arm64/kernel/cpufeature.c=1708=static int __init aarch32_el0_sysfs_init(void)
--
arch/arm64/kernel/cpufeature.c-1717- if (dev_root) {
arch/arm64/kernel/cpufeature.c:1718: ret = device_create_file(dev_root, &dev_attr_aarch32_el0);
arch/arm64/kernel/cpufeature.c-1719- put_device(dev_root);
--
arch/arm64/kernel/mte.c=617=static int register_mte_tcf_preferred_sysctl(void)
--
arch/arm64/kernel/mte.c-625- per_cpu(mte_tcf_preferred, cpu) = MTE_CTRL_TCF_ASYNC;
arch/arm64/kernel/mte.c:626: device_create_file(get_cpu_device(cpu),
arch/arm64/kernel/mte.c-627- &dev_attr_mte_tcf_preferred);
--
arch/powerpc/kernel/eeh_sysfs.c=110=static int eeh_notify_resume_add(struct pci_dev *pdev)
--
arch/powerpc/kernel/eeh_sysfs.c-117- if (of_property_read_bool(np, "ibm,is-open-sriov-pf"))
arch/powerpc/kernel/eeh_sysfs.c:118: rc = device_create_file(&pdev->dev, &dev_attr_eeh_notify_resume);
arch/powerpc/kernel/eeh_sysfs.c-119-
--
arch/powerpc/kernel/eeh_sysfs.c=137=void eeh_sysfs_add_device(struct pci_dev *pdev)
--
arch/powerpc/kernel/eeh_sysfs.c-147-
arch/powerpc/kernel/eeh_sysfs.c:148: rc += device_create_file(&pdev->dev, &dev_attr_eeh_mode);
arch/powerpc/kernel/eeh_sysfs.c:149: rc += device_create_file(&pdev->dev, &dev_attr_eeh_pe_config_addr);
arch/powerpc/kernel/eeh_sysfs.c:150: rc += device_create_file(&pdev->dev, &dev_attr_eeh_pe_state);
arch/powerpc/kernel/eeh_sysfs.c-151- rc += eeh_notify_resume_add(pdev);
--
arch/powerpc/kernel/iommu.c=162=static int fail_iommu_bus_notify(struct notifier_block *nb,
--
arch/powerpc/kernel/iommu.c-167- if (action == BUS_NOTIFY_ADD_DEVICE) {
arch/powerpc/kernel/iommu.c:168: if (device_create_file(dev, &dev_attr_fail_iommu))
arch/powerpc/kernel/iommu.c-169- pr_warn("Unable to create IOMMU fault injection sysfs "
--
arch/powerpc/kernel/sysfs.c=219=static void __init sysfs_create_dscr_default(void)
--
arch/powerpc/kernel/sysfs.c-230- if (dev_root) {
arch/powerpc/kernel/sysfs.c:231: device_create_file(dev_root, &dev_attr_dscr_default);
arch/powerpc/kernel/sysfs.c-232- put_device(dev_root);
--
arch/powerpc/kernel/sysfs.c=754=static void __init create_svm_file(void)
--
arch/powerpc/kernel/sysfs.c-758- if (dev_root) {
arch/powerpc/kernel/sysfs.c:759: device_create_file(dev_root, &dev_attr_svm);
arch/powerpc/kernel/sysfs.c-760- put_device(dev_root);
--
arch/powerpc/kernel/sysfs.c=788=static void create_idle_purr_file(struct device *s)
--
arch/powerpc/kernel/sysfs.c-790- if (firmware_has_feature(FW_FEATURE_LPAR))
arch/powerpc/kernel/sysfs.c:791: device_create_file(s, &dev_attr_idle_purr);
arch/powerpc/kernel/sysfs.c-792-}
--
arch/powerpc/kernel/sysfs.c=818=static void create_idle_spurr_file(struct device *s)
--
arch/powerpc/kernel/sysfs.c-820- if (firmware_has_feature(FW_FEATURE_LPAR))
arch/powerpc/kernel/sysfs.c:821: device_create_file(s, &dev_attr_idle_spurr);
arch/powerpc/kernel/sysfs.c-822-}
--
arch/powerpc/kernel/sysfs.c=837=static int register_cpu_online(unsigned int cpu)
--
arch/powerpc/kernel/sysfs.c-849- if (cpu_has_feature(CPU_FTR_SMT))
arch/powerpc/kernel/sysfs.c:850: device_create_file(s, &dev_attr_smt_snooze_delay);
arch/powerpc/kernel/sysfs.c-851-#endif
--
arch/powerpc/kernel/sysfs.c-883- for (i = 0; i < nattrs; i++)
arch/powerpc/kernel/sysfs.c:884: device_create_file(s, &attrs[i]);
arch/powerpc/kernel/sysfs.c-885-
--
arch/powerpc/kernel/sysfs.c-887- for (i = 0; i < cur_cpu_spec->num_pmcs; i++)
arch/powerpc/kernel/sysfs.c:888: device_create_file(s, &pmc_attrs[i]);
arch/powerpc/kernel/sysfs.c-889-
--
arch/powerpc/kernel/sysfs.c-892- if (cpu_has_feature(CPU_FTR_MMCRA))
arch/powerpc/kernel/sysfs.c:893: device_create_file(s, &dev_attr_mmcra);
arch/powerpc/kernel/sysfs.c-894-
arch/powerpc/kernel/sysfs.c-895- if (cpu_has_feature(CPU_FTR_ARCH_31))
arch/powerpc/kernel/sysfs.c:896: device_create_file(s, &dev_attr_mmcr3);
arch/powerpc/kernel/sysfs.c-897-#endif /* CONFIG_PMU_SYSFS */
--
arch/powerpc/kernel/sysfs.c-901- add_write_permission_dev_attr(&dev_attr_purr);
arch/powerpc/kernel/sysfs.c:902: device_create_file(s, &dev_attr_purr);
arch/powerpc/kernel/sysfs.c-903- create_idle_purr_file(s);
--
arch/powerpc/kernel/sysfs.c-906- if (cpu_has_feature(CPU_FTR_SPURR)) {
arch/powerpc/kernel/sysfs.c:907: device_create_file(s, &dev_attr_spurr);
arch/powerpc/kernel/sysfs.c-908- create_idle_spurr_file(s);
--
arch/powerpc/kernel/sysfs.c-911- if (cpu_has_feature(CPU_FTR_DSCR))
arch/powerpc/kernel/sysfs.c:912: device_create_file(s, &dev_attr_dscr);
arch/powerpc/kernel/sysfs.c-913-
arch/powerpc/kernel/sysfs.c-914- if (cpu_has_feature(CPU_FTR_PPCAS_ARCH_V2))
arch/powerpc/kernel/sysfs.c:915: device_create_file(s, &dev_attr_pir);
arch/powerpc/kernel/sysfs.c-916-
--
arch/powerpc/kernel/sysfs.c-918- !firmware_has_feature(FW_FEATURE_LPAR))
arch/powerpc/kernel/sysfs.c:919: device_create_file(s, &dev_attr_tscr);
arch/powerpc/kernel/sysfs.c-920-#endif /* CONFIG_PPC64 */
--
arch/powerpc/kernel/sysfs.c-923- if (PVR_VER(cur_cpu_spec->pvr_value) == PVR_VER_E6500) {
arch/powerpc/kernel/sysfs.c:924: device_create_file(s, &dev_attr_pw20_state);
arch/powerpc/kernel/sysfs.c:925: device_create_file(s, &dev_attr_pw20_wait_time);
arch/powerpc/kernel/sysfs.c-926-
arch/powerpc/kernel/sysfs.c:927: device_create_file(s, &dev_attr_altivec_idle);
arch/powerpc/kernel/sysfs.c:928: device_create_file(s, &dev_attr_altivec_idle_wait_time);
arch/powerpc/kernel/sysfs.c-929- }
--
arch/powerpc/kernel/sysfs.c=1056=int cpu_add_dev_attr(struct device_attribute *attr)
--
arch/powerpc/kernel/sysfs.c-1062- for_each_possible_cpu(cpu) {
arch/powerpc/kernel/sysfs.c:1063: device_create_file(get_cpu_device(cpu), attr);
arch/powerpc/kernel/sysfs.c-1064- }
--
arch/powerpc/kernel/sysfs.c=1151=static int __init topology_init(void)
--
arch/powerpc/kernel/sysfs.c-1172-
arch/powerpc/kernel/sysfs.c:1173: device_create_file(&c->dev, &dev_attr_physical_id);
arch/powerpc/kernel/sysfs.c-1174- }
--
arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c=144=static int mcu_probe(struct i2c_client *client)
--
arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c-172-
arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c:173: if (device_create_file(&client->dev, &dev_attr_status))
arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c-174- dev_err(&client->dev,
--
arch/powerpc/platforms/cell/spu_base.c=473=int spu_add_dev_attr(struct device_attribute *attr)
--
arch/powerpc/platforms/cell/spu_base.c-478- list_for_each_entry(spu, &spu_full_list, full_list)
arch/powerpc/platforms/cell/spu_base.c:479: device_create_file(&spu->dev, attr);
arch/powerpc/platforms/cell/spu_base.c-480- mutex_unlock(&spu_full_list_mutex);
--
arch/powerpc/platforms/powernv/idle.c=1429=static int __init pnv_init_idle_states(void)
--
arch/powerpc/platforms/powernv/idle.c-1478- if (dev_root) {
arch/powerpc/platforms/powernv/idle.c:1479: device_create_file(dev_root,
arch/powerpc/platforms/powernv/idle.c-1480- &dev_attr_fastsleep_workaround_applyonce);
--
arch/powerpc/platforms/powernv/subcore.c=419=static int subcore_init(void)
--
arch/powerpc/platforms/powernv/subcore.c-445- if (dev_root) {
arch/powerpc/platforms/powernv/subcore.c:446: rc = device_create_file(dev_root, &dev_attr_subcores_per_core);
arch/powerpc/platforms/powernv/subcore.c-447- put_device(dev_root);
--
arch/powerpc/platforms/pseries/cmm.c=392=static int cmm_sysfs_register(struct device *dev)
--
arch/powerpc/platforms/pseries/cmm.c-406- for (i = 0; i < ARRAY_SIZE(cmm_attrs); i++) {
arch/powerpc/platforms/pseries/cmm.c:407: if ((rc = device_create_file(dev, cmm_attrs[i])))
arch/powerpc/platforms/pseries/cmm.c-408- goto fail;
--
arch/powerpc/platforms/pseries/cmm.c-412- return 0;
arch/powerpc/platforms/pseries/cmm.c:413: rc = device_create_file(dev, &dev_attr_simulate_loan_target_kb.attr);
arch/powerpc/platforms/pseries/cmm.c-414- if (rc)
--
arch/powerpc/platforms/pseries/pseries_energy.c=301=static int __init pseries_energy_init(void)
--
arch/powerpc/platforms/pseries/pseries_energy.c-311- if (dev_root) {
arch/powerpc/platforms/pseries/pseries_energy.c:312: err = device_create_file(dev_root, &attr_cpu_activate_hint_list);
arch/powerpc/platforms/pseries/pseries_energy.c-313- if (!err)
arch/powerpc/platforms/pseries/pseries_energy.c:314: err = device_create_file(dev_root, &attr_cpu_deactivate_hint_list);
arch/powerpc/platforms/pseries/pseries_energy.c-315- put_device(dev_root);
--
arch/powerpc/platforms/pseries/pseries_energy.c-321- cpu_dev = get_cpu_device(cpu);
arch/powerpc/platforms/pseries/pseries_energy.c:322: err = device_create_file(cpu_dev,
arch/powerpc/platforms/pseries/pseries_energy.c-323- &attr_percpu_activate_hint);
--
arch/powerpc/platforms/pseries/pseries_energy.c-325- break;
arch/powerpc/platforms/pseries/pseries_energy.c:326: err = device_create_file(cpu_dev,
arch/powerpc/platforms/pseries/pseries_energy.c-327- &attr_percpu_deactivate_hint);
--
arch/powerpc/platforms/pseries/suspend.c=146=static int pseries_suspend_sysfs_register(struct device *dev)
--
arch/powerpc/platforms/pseries/suspend.c-158- if (dev_root) {
arch/powerpc/platforms/pseries/suspend.c:159: rc = device_create_file(dev_root, &dev_attr_hibernate);
arch/powerpc/platforms/pseries/suspend.c-160- put_device(dev_root);
--
arch/powerpc/sysdev/fsl_mpic_timer_wakeup.c=110=static int __init fsl_wakeup_sys_init(void)
--
arch/powerpc/sysdev/fsl_mpic_timer_wakeup.c-122- if (dev_root) {
arch/powerpc/sysdev/fsl_mpic_timer_wakeup.c:123: ret = device_create_file(dev_root, &mpic_attributes);
arch/powerpc/sysdev/fsl_mpic_timer_wakeup.c-124- put_device(dev_root);
--
arch/s390/kernel/smp.c=1149=static int __init s390_smp_init(void)
--
arch/s390/kernel/smp.c-1155- if (dev_root) {
arch/s390/kernel/smp.c:1156: rc = device_create_file(dev_root, &dev_attr_rescan);
arch/s390/kernel/smp.c-1157- put_device(dev_root);
--
arch/s390/kernel/topology.c=681=static int __init topology_init(void)
--
arch/s390/kernel/topology.c-696- if (dev_root) {
arch/s390/kernel/topology.c:697: rc = device_create_file(dev_root, &dev_attr_dispatching);
arch/s390/kernel/topology.c-698- put_device(dev_root);
--
arch/sh/drivers/dma/dma-sysfs.c=46=static int __init dma_subsys_init(void)
--
arch/sh/drivers/dma/dma-sysfs.c-56- if (dev_root) {
arch/sh/drivers/dma/dma-sysfs.c:57: ret = device_create_file(dev_root, &dev_attr_devices);
arch/sh/drivers/dma/dma-sysfs.c-58- put_device(dev_root);
--
arch/sh/drivers/dma/dma-sysfs.c=127=int dma_create_sysfs_files(struct dma_channel *chan, struct dma_info *info)
--
arch/sh/drivers/dma/dma-sysfs.c-139-
arch/sh/drivers/dma/dma-sysfs.c:140: ret |= device_create_file(dev, &dev_attr_dev_id);
arch/sh/drivers/dma/dma-sysfs.c:141: ret |= device_create_file(dev, &dev_attr_count);
arch/sh/drivers/dma/dma-sysfs.c:142: ret |= device_create_file(dev, &dev_attr_mode);
arch/sh/drivers/dma/dma-sysfs.c:143: ret |= device_create_file(dev, &dev_attr_flags);
arch/sh/drivers/dma/dma-sysfs.c:144: ret |= device_create_file(dev, &dev_attr_config);
arch/sh/drivers/dma/dma-sysfs.c-145-
--
arch/sh/drivers/push-switch.c=43=static int switch_drv_probe(struct platform_device *pdev)
--
arch/sh/drivers/push-switch.c-68- if (psw_info->name) {
arch/sh/drivers/push-switch.c:69: ret = device_create_file(&pdev->dev, &dev_attr_switch);
arch/sh/drivers/push-switch.c-70- if (unlikely(ret)) {
--
arch/sparc/kernel/sysfs.c=154=static int register_mmu_stats(struct device *s)
--
arch/sparc/kernel/sysfs.c-157- return 0;
arch/sparc/kernel/sysfs.c:158: device_create_file(s, &dev_attr_mmustat_enable);
arch/sparc/kernel/sysfs.c-159- return sysfs_create_group(&s->kobj, &mmu_stat_group);
--
arch/sparc/kernel/sysfs.c=208=static int register_cpu_online(unsigned int cpu)
--
arch/sparc/kernel/sysfs.c-214- for (i = 0; i < ARRAY_SIZE(cpu_core_attrs); i++)
arch/sparc/kernel/sysfs.c:215: device_create_file(s, &cpu_core_attrs[i]);
arch/sparc/kernel/sysfs.c-216-
--
arch/x86/kernel/cpu/mce/core.c=2659=static int mce_device_create(unsigned int cpu)
--
arch/x86/kernel/cpu/mce/core.c-2682- for (i = 0; mce_device_attrs[i]; i++) {
arch/x86/kernel/cpu/mce/core.c:2683: err = device_create_file(dev, mce_device_attrs[i]);
arch/x86/kernel/cpu/mce/core.c-2684- if (err)
--
arch/x86/kernel/cpu/mce/core.c-2687- for (j = 0; j < per_cpu(mce_num_banks, cpu); j++) {
arch/x86/kernel/cpu/mce/core.c:2688: err = device_create_file(dev, &mce_bank_devs[j].attr);
arch/x86/kernel/cpu/mce/core.c-2689- if (err)
--
block/partitions/core.c=295=static struct block_device *add_partition(struct gendisk *disk, int partno,
--
block/partitions/core.c-377- if (flags & ADDPART_FLAG_WHOLEDISK) {
block/partitions/core.c:378: err = device_create_file(pdev, &dev_attr_whole_disk);
block/partitions/core.c-379- if (err)
--
drivers/acpi/power.c=933=struct acpi_device *acpi_add_power_resource(acpi_handle handle)
--
drivers/acpi/power.c-981-
drivers/acpi/power.c:982: if (!device_create_file(&device->dev, &dev_attr_resource_in_use))
drivers/acpi/power.c-983- device->remove = acpi_power_sysfs_remove;
--
drivers/ata/sata_fsl.c=1423=static int sata_fsl_probe(struct platform_device *ofdev)
--
drivers/ata/sata_fsl.c-1500- host_priv->intr_coalescing.attr.mode = S_IRUGO | S_IWUSR;
drivers/ata/sata_fsl.c:1501: retval = device_create_file(host->dev, &host_priv->intr_coalescing);
drivers/ata/sata_fsl.c-1502- if (retval)
--
drivers/ata/sata_fsl.c-1509- host_priv->rx_watermark.attr.mode = S_IRUGO | S_IWUSR;
drivers/ata/sata_fsl.c:1510: retval = device_create_file(host->dev, &host_priv->rx_watermark);
drivers/ata/sata_fsl.c-1511- if (retval) {
--
drivers/atm/solos-pci.c=1348=static int atm_init(struct solos_card *card, struct device *parent)
--
drivers/atm/solos-pci.c-1364- }
drivers/atm/solos-pci.c:1365: if (device_create_file(&card->atmdev[i]->class_dev, &dev_attr_console))
drivers/atm/solos-pci.c-1366- dev_err(&card->dev->dev, "Could not register console for ATM device %d\n", i);
--
drivers/base/attribute_container.c=387=attribute_container_add_attrs(struct device *classdev)
--
drivers/base/attribute_container.c-403- sysfs_attr_init(&attrs[i]->attr);
drivers/base/attribute_container.c:404: error = device_create_file(classdev, attrs[i]);
drivers/base/attribute_container.c-405- if (error)
--
drivers/base/core.c=2964=static int device_add_attrs(struct device *dev)
--
drivers/base/core.c-2986- if (device_supports_offline(dev) && !dev_offline_disabled(dev)) {
drivers/base/core.c:2987: error = device_create_file(dev, &dev_attr_online);
drivers/base/core.c-2988- if (error)
--
drivers/base/core.c-2992- if (fw_devlink_flags && !fw_devlink_is_permissive() && dev->fwnode) {
drivers/base/core.c:2993: error = device_create_file(dev, &dev_attr_waiting_for_supplier);
drivers/base/core.c-2994- if (error)
--
drivers/base/core.c-2998- if (dev_removable_is_valid(dev)) {
drivers/base/core.c:2999: error = device_create_file(dev, &dev_attr_removable);
drivers/base/core.c-3000- if (error)
--
drivers/base/core.c=3099=void devices_kset_move_last(struct device *dev)
--
drivers/base/core.c-3109-/**
drivers/base/core.c:3110: * device_create_file - create sysfs attribute file for device.
drivers/base/core.c-3111- * @dev: device.
--
drivers/base/core.c-3113- */
drivers/base/core.c:3114:int device_create_file(struct device *dev,
drivers/base/core.c-3115- const struct device_attribute *attr)
--
drivers/base/core.c-3130-}
drivers/base/core.c:3131:EXPORT_SYMBOL_GPL(device_create_file);
drivers/base/core.c-3132-
--
drivers/base/core.c=3639=int device_add(struct device *dev)
--
drivers/base/core.c-3703-
drivers/base/core.c:3704: error = device_create_file(dev, &dev_attr_uevent);
drivers/base/core.c-3705- if (error)
--
drivers/base/core.c-3722- if (MAJOR(dev->devt)) {
drivers/base/core.c:3723: error = device_create_file(dev, &dev_attr_dev);
drivers/base/core.c-3724- if (error)
--
drivers/base/dd.c=483=static int driver_sysfs_add(struct device *dev)
--
drivers/base/dd.c-501-
drivers/base/dd.c:502: ret = device_create_file(dev, &dev_attr_coredump);
drivers/base/dd.c-503- if (!ret)
--
drivers/base/dd.c=652=static int really_probe(struct device *dev, const struct device_driver *drv)
--
drivers/base/dd.c-731- if (dev_has_sync_state(dev)) {
drivers/base/dd.c:732: ret = device_create_file(dev, &dev_attr_state_synced);
drivers/base/dd.c-733- if (ret) {
--
drivers/base/topology.c=231=static int cpu_capacity_sysctl_add(unsigned int cpu)
--
drivers/base/topology.c-237-
drivers/base/topology.c:238: device_create_file(cpu_dev, &dev_attr_cpu_capacity);
drivers/base/topology.c-239-
--
drivers/block/nbd.c=1508=static int nbd_start_device(struct nbd_device *nbd)
--
drivers/block/nbd.c-1538-
drivers/block/nbd.c:1539: error = device_create_file(disk_to_dev(nbd->disk), &pid_attr);
drivers/block/nbd.c-1540- if (error) {
drivers/block/nbd.c:1541: dev_err(disk_to_dev(nbd->disk), "device_create_file failed for pid!\n");
drivers/block/nbd.c-1542- return error;
--
drivers/block/nbd.c=2110=static int nbd_genl_connect(struct sk_buff *skb, struct genl_info *info)
--
drivers/block/nbd.c-2267- }
drivers/block/nbd.c:2268: ret = device_create_file(disk_to_dev(nbd->disk), &backend_attr);
drivers/block/nbd.c-2269- if (ret) {
drivers/block/nbd.c-2270- dev_err(disk_to_dev(nbd->disk),
drivers/block/nbd.c:2271: "device_create_file failed for backend!\n");
drivers/block/nbd.c-2272- goto out;
--
drivers/block/xen-blkback/xenbus.c=441=static int xenvbd_sysfs_addif(struct xenbus_device *dev)
--
drivers/block/xen-blkback/xenbus.c-444-
drivers/block/xen-blkback/xenbus.c:445: error = device_create_file(&dev->dev, &dev_attr_physical_device);
drivers/block/xen-blkback/xenbus.c-446- if (error)
--
drivers/block/xen-blkback/xenbus.c-448-
drivers/block/xen-blkback/xenbus.c:449: error = device_create_file(&dev->dev, &dev_attr_mode);
drivers/block/xen-blkback/xenbus.c-450- if (error)
--
drivers/char/ipmi/ipmi_msghandler.c=3614=int ipmi_add_smi(struct module *owner,
--
drivers/char/ipmi/ipmi_msghandler.c-3726- sysfs_attr_init(&intf->nr_users_devattr.attr);
drivers/char/ipmi/ipmi_msghandler.c:3727: rv = device_create_file(intf->si_dev, &intf->nr_users_devattr);
drivers/char/ipmi/ipmi_msghandler.c-3728- if (rv)
--
drivers/char/ipmi/ipmi_msghandler.c-3732- sysfs_attr_init(&intf->nr_msgs_devattr.attr);
drivers/char/ipmi/ipmi_msghandler.c:3733: rv = device_create_file(intf->si_dev, &intf->nr_msgs_devattr);
drivers/char/ipmi/ipmi_msghandler.c-3734- if (rv) {
--
drivers/char/ipmi/ipmi_msghandler.c-3740- sysfs_attr_init(&intf->maintenance_mode_devattr.attr);
drivers/char/ipmi/ipmi_msghandler.c:3741: rv = device_create_file(intf->si_dev, &intf->maintenance_mode_devattr);
drivers/char/ipmi/ipmi_msghandler.c-3742- if (rv) {
--
drivers/crypto/marvell/octeontx/otx_cptpf_ucode.c=820=static int create_sysfs_eng_grps_info(struct device *dev,
--
drivers/crypto/marvell/octeontx/otx_cptpf_ucode.c-827- sysfs_attr_init(&eng_grp->info_attr.attr);
drivers/crypto/marvell/octeontx/otx_cptpf_ucode.c:828: return device_create_file(dev, &eng_grp->info_attr);
drivers/crypto/marvell/octeontx/otx_cptpf_ucode.c-829-}
--
drivers/crypto/marvell/octeontx/otx_cptpf_ucode.c=1611=int otx_cpt_init_eng_grps(struct pci_dev *pdev,
--
drivers/crypto/marvell/octeontx/otx_cptpf_ucode.c-1671- sysfs_attr_init(&eng_grps->ucode_load_attr.attr);
drivers/crypto/marvell/octeontx/otx_cptpf_ucode.c:1672: ret = device_create_file(&pdev->dev,
drivers/crypto/marvell/octeontx/otx_cptpf_ucode.c-1673- &eng_grps->ucode_load_attr);
--
drivers/dio/dio-sysfs.c=67=int dio_create_sysfs_dev_files(struct dio_dev *d)
--
drivers/dio/dio-sysfs.c-72- /* current configuration's attributes */
drivers/dio/dio-sysfs.c:73: if ((error = device_create_file(dev, &dev_attr_id)) ||
drivers/dio/dio-sysfs.c:74: (error = device_create_file(dev, &dev_attr_ipl)) ||
drivers/dio/dio-sysfs.c:75: (error = device_create_file(dev, &dev_attr_secid)) ||
drivers/dio/dio-sysfs.c:76: (error = device_create_file(dev, &dev_attr_name)) ||
drivers/dio/dio-sysfs.c:77: (error = device_create_file(dev, &dev_attr_resource)))
drivers/dio/dio-sysfs.c-78- return error;
--
drivers/dma/qcom/hidma.c=660=static int hidma_sysfs_init(struct hidma_dev *dev)
--
drivers/dma/qcom/hidma.c-665-
drivers/dma/qcom/hidma.c:666: return device_create_file(dev->ddev.dev, dev->chid_attrs);
drivers/dma/qcom/hidma.c-667-}
--
drivers/dma/qcom/hidma_mgmt_sys.c=182=static int create_sysfs_entry(struct hidma_mgmt_dev *dev, char *name, int mode)
--
drivers/dma/qcom/hidma_mgmt_sys.c-201-
drivers/dma/qcom/hidma_mgmt_sys.c:202: return device_create_file(&dev->pdev->dev, attrs);
drivers/dma/qcom/hidma_mgmt_sys.c-203-}
--
drivers/edac/synopsys_edac.c=1115=static int edac_create_sysfs_attributes(struct mem_ctl_info *mci)
--
drivers/edac/synopsys_edac.c-1118-
drivers/edac/synopsys_edac.c:1119: rc = device_create_file(&mci->dev, &dev_attr_inject_data_error);
drivers/edac/synopsys_edac.c-1120- if (rc < 0)
drivers/edac/synopsys_edac.c-1121- return rc;
drivers/edac/synopsys_edac.c:1122: rc = device_create_file(&mci->dev, &dev_attr_inject_data_poison);
drivers/edac/synopsys_edac.c-1123- if (rc < 0)
--
drivers/eisa/eisa-bus.c=226=static int __init eisa_register_device(struct eisa_device *edev)
--
drivers/eisa/eisa-bus.c-233-
drivers/eisa/eisa-bus.c:234: rc = device_create_file(&edev->dev, &dev_attr_signature);
drivers/eisa/eisa-bus.c-235- if (rc)
drivers/eisa/eisa-bus.c-236- goto err_devreg;
drivers/eisa/eisa-bus.c:237: rc = device_create_file(&edev->dev, &dev_attr_enabled);
drivers/eisa/eisa-bus.c-238- if (rc)
drivers/eisa/eisa-bus.c-239- goto err_sig;
drivers/eisa/eisa-bus.c:240: rc = device_create_file(&edev->dev, &dev_attr_modalias);
drivers/eisa/eisa-bus.c-241- if (rc)
--
drivers/fsi/fsi-master-aspeed.c=467=static int setup_cfam_reset(struct fsi_master_aspeed *aspeed)
--
drivers/fsi/fsi-master-aspeed.c-480-
drivers/fsi/fsi-master-aspeed.c:481: rc = device_create_file(dev, &dev_attr_cfam_reset);
drivers/fsi/fsi-master-aspeed.c-482- if (rc) {
--
drivers/fsi/fsi-master-ast-cf.c=1213=static int fsi_master_acf_probe(struct platform_device *pdev)
--
drivers/fsi/fsi-master-ast-cf.c-1383-
drivers/fsi/fsi-master-ast-cf.c:1384: rc = device_create_file(&pdev->dev, &dev_attr_external_mode);
drivers/fsi/fsi-master-ast-cf.c-1385- if (rc)
--
drivers/fsi/fsi-master-gpio.c=771=static int fsi_master_gpio_probe(struct platform_device *pdev)
--
drivers/fsi/fsi-master-gpio.c-851-
drivers/fsi/fsi-master-gpio.c:852: rc = device_create_file(&pdev->dev, &dev_attr_external_mode);
drivers/fsi/fsi-master-gpio.c-853- if (rc)
--
drivers/fsi/fsi-sbefifo.c=1025=static int sbefifo_probe(struct fsi_device *fsi_dev)
--
drivers/fsi/fsi-sbefifo.c-1082-
drivers/fsi/fsi-sbefifo.c:1083: device_create_file(&sbefifo->dev, &dev_attr_timeout);
drivers/fsi/fsi-sbefifo.c-1084-
--
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c=1990=static int amdgpu_gfx_sysfs_xcp_init(struct amdgpu_device *adev)
--
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c-2005-
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c:2006: r = device_create_file(adev->dev, &dev_attr_current_compute_partition);
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c-2007- if (r)
]
|
| 58/2 |
2026/07/31 07:20 |
llm |
debugger |
0m
Model:
Tokens:
input: 62420
output: 23
thoughts: 39
Thoughts: Okay, here's my interpretation of that thought process, tailored for an expert audience, and written in the first person:
**Initial Investigation into a Device Driver Function Call**
Right, so `device_create_file` is the key function being used here. That immediately tells me this driver, presumably `cxacru.c`, is attempting to expose some kind of attribute or file interface within the sysfs hierarchy. Given my familiarity with how these systems are architected, I need to understand what specific attributes are being created and how they are handled. So, letβs go and dig a little deeper. I'm going to run a `grep` for `device_create_file` within the `drivers/usb/atm/cxacru.c` file. This should help to identify the specific file names being created and associated operations. From there, I can analyze the context surrounding these calls, and that should quickly give me the necessary information to determine what information or control interface the driver is providing to user space.
|
| 59/2 |
2026/07/31 07:20 |
tool |
grepper |
0m
Error:
Args: map[Expression:device_create_file.*cxacru]
Results:
|
| 60/2 |
2026/07/31 07:20 |
llm |
debugger |
0m
Model:
Tokens:
input: 62709
output: 31
thoughts: 21
Thoughts: Here's my thought process, as if I were considering this myself:
**Investigating USB ATM Driver Device File Creation**
Okay, so I need to understand how device files are being created for USB ATM devices. My first instinct is to zero in on the function responsible for actually *creating* these files. The most likely candidate function name, based on general Linux device driver knowledge, would be something like `device_create_file`. So, let's start with a focused search. My plan is to grep the `drivers/usb/atm/` directory. That's where the USB ATM driver code should reside, and where I expect to find the relevant code responsible for file creation. I'll use grep to look for instances of `device_create_file`, which should give me a good starting point to dig further into how the file creation process is implemented within the USB ATM driver framework. This is a targeted approach - Iβm looking for a specific function within a reasonably well-defined area of the kernel source.
|
| 61/2 |
2026/07/31 07:20 |
tool |
grepper |
0m
Error:
Args: map[Expression:device_create_file PathPrefix:drivers/usb/atm/]
Results:
|
| 62/2 |
2026/07/31 07:20 |
llm |
debugger |
0m
Model:
Tokens:
input: 62988
output: 32
thoughts: 33
Thoughts: Okay, here's my take on those thoughts, framed for an expert like myself:
**Delving into Sysfs Attribute Creation**
Hmm, interesting. I'm hitting a point where I need to understand the mechanics of how these `sysfs` attributes are actually brought into existence. It's not always immediately obvious, and that underlying structure can be crucial for debugging or modifying driver behavior.
Right, so to get a handle on this, let's see how this is done in a sample driver. I think USB ATM would be a great place to start, so let's use a `grep` for `sysfs_create_group`. I'll run this from the `drivers/usb/atm/` directory. That should give me a specific case to look at, probably a good example of how to make sysfs attributes for the USB ATM device. And that ought to give a good starting point to understanding what's going on!
|
| 63/2 |
2026/07/31 07:20 |
tool |
grepper |
0m
Error:
Args: map[Expression:sysfs_create_group PathPrefix:drivers/usb/atm/]
Results:
|
| 64/2 |
2026/07/31 07:20 |
llm |
debugger |
0m
Model:
Tokens:
input: 63266
output: 64
thoughts: 41
Thoughts: Okay, here's my take on those thoughts, framed as an expert's internal monologue:
**Investigating CXACRU Driver Sysfs Interaction**
Right, let's dive into the `cxacru.c` driver in the USB ATM subsystem. I need to understand how this driver interacts with sysfs. Specifically, I want to see how it exposes its functionality and device information to userspace. My first instinct is to look for those key sysfs creation functions. I'll start with a `grep` through the code, targeting functions that create device files, like `device_create_file`. Then I'll expand that to check for `sysfs_create` calls, as that's a common method for creating attributes directly under the device's directory in sysfs. And I'll be sure to hunt for any usage of `device_add_groups` too; that can be critical for defining the attribute groupings visible to the user. Hopefully, this should quickly illuminate how the driver presents itself to the system and lets me pinpoint where its control mechanisms might be.
|
| 65/2 |
2026/07/31 07:20 |
tool |
grepper |
0m
Error:
Args: map[Expression:device_create_file|sysfs_create|device_add_groups|device_create_bin_file|sysfs_create_bin_file PathPrefix:drivers/usb/atm/cxacru.c]
Results:
|
| 66/2 |
2026/07/31 07:20 |
llm |
debugger |
0m
Model:
Tokens:
input: 63611
output: 36
thoughts: 22
Thoughts: Here's a summary of my thought process:
**Diving Back into the `cxacru.c` Code**
Okay, I'm going to revisit that `cxacru.c` file. Specifically, I need to use `grep` again, and this time, I'm searching for `device_create_file`. I remember we were looking at some device file creation issues related to this module earlier, and I need to refresh my memory and see if I can spot anything I missed or if I can confirm a previous line of thought. Let's see what pops up this time. I suspect I might find the context I need surrounding device file permissions or naming conflicts.
|
| 67/2 |
2026/07/31 07:20 |
tool |
grepper |
0m
Error:
Args: map[Expression:device_create_file PathPrefix:drivers/usb/atm/cxacru.c]
Results:
|
| 68/2 |
2026/07/31 07:20 |
llm |
debugger |
0m
Model:
Tokens:
input: 63827
output: 25
thoughts: 26
Thoughts: Okay, let me think this through.
**Digging into Attribute Creation**
Hmm, so I need to understand this process more deeply. Specifically, I'm trying to figure out the actual mechanism of how these attributes get created. It's not immediately obvious. Okay, let's start with `CXACRU_ALL_FILES(INIT)`. That seems like a logical entry point, particularly the initialization stage. Let's see what's happening there and unravel this mystery. I need to understand this attribute creation process.
|
| 69/2 |
2026/07/31 07:21 |
tool |
codesearch-definition-source |
0m
Error:
Args: map[Name:CXACRU_ALL_FILES]
Results: map[SourceCode: SourceFile:]
|
| 70/2 |
2026/07/31 07:21 |
llm |
debugger |
0m
Model:
Tokens:
input: 64010
output: 23
thoughts: 12
Thoughts: Okay, let's dive into this `cxacru_bind` function. I'm already anticipating some of the usual suspects β likely handling context setup, resource binding, possibly some parameter validation, and then the actual binding operation itself. Given the "cxacru" prefix, I'd wager it's related to some context-aware or cross-context resource management. I'm expecting some sort of handle or identifier to be passed in for the resource, another for the context, and maybe some flags or options to control the bind behavior. I'll need to pay close attention to error handling β are there specific error codes for different failure scenarios? Are they documented clearly? Are there checks for null pointers or invalid handles? I'll be particularly interested in how it handles concurrency and thread safety if this is in a multi-threaded environment. I'll also be on the lookout for memory management aspects, like is it the caller's responsibility to manage the memory associated with what's being bound or is the function doing some internal allocation? Finally, I'll need to check the return value, is it a success or a fail code, and I need to determine how the failure is reported back.
|
| 71/2 |
2026/07/31 07:21 |
tool |
codesearch-definition-source |
0m
Args:
Results: map[SourceCode:1120: static int cxacru_bind(struct usbatm_data *usbatm_instance,
1121: struct usb_interface *intf, const struct usb_device_id *id)
1122: {
1123: struct cxacru_data *instance;
1124: struct usb_device *usb_dev = interface_to_usbdev(intf);
1125: struct usb_host_endpoint *cmd_ep = usb_dev->ep_in[CXACRU_EP_CMD];
1126: static const u8 ep_addrs[] = {
1127: CXACRU_EP_CMD + USB_DIR_IN,
1128: CXACRU_EP_CMD + USB_DIR_OUT,
1129: 0};
1130: int ret;
1131:
1132: /* instance init */
1133: instance = kzalloc_obj(*instance);
1134: if (!instance)
1135: return -ENOMEM;
1136:
1137: instance->usbatm = usbatm_instance;
1138: instance->modem_type = (struct cxacru_modem_type *) id->driver_info;
1139:
1140: mutex_init(&instance->poll_state_serialize);
1141: instance->poll_state = CXPOLL_STOPPED;
1142: instance->line_status = -1;
1143: instance->adsl_status = -1;
1144:
1145: mutex_init(&instance->adsl_state_serialize);
1146:
1147: instance->rcv_buf = (u8 *) __get_free_page(GFP_KERNEL);
1148: if (!instance->rcv_buf) {
1149: usb_dbg(usbatm_instance, "cxacru_bind: no memory for rcv_buf\n");
1150: ret = -ENOMEM;
1151: goto fail;
1152: }
1153: instance->snd_buf = (u8 *) __get_free_page(GFP_KERNEL);
1154: if (!instance->snd_buf) {
1155: usb_dbg(usbatm_instance, "cxacru_bind: no memory for snd_buf\n");
1156: ret = -ENOMEM;
1157: goto fail;
1158: }
1159: instance->rcv_urb = usb_alloc_urb(0, GFP_KERNEL);
1160: if (!instance->rcv_urb) {
1161: ret = -ENOMEM;
1162: goto fail;
1163: }
1164: instance->snd_urb = usb_alloc_urb(0, GFP_KERNEL);
1165: if (!instance->snd_urb) {
1166: ret = -ENOMEM;
1167: goto fail;
1168: }
1169:
1170: if (!cmd_ep) {
1171: usb_dbg(usbatm_instance, "cxacru_bind: no command endpoint\n");
1172: ret = -ENODEV;
1173: goto fail;
1174: }
1175:
1176: if (usb_endpoint_xfer_int(&cmd_ep->desc))
1177: ret = usb_check_int_endpoints(intf, ep_addrs);
1178: else
1179: ret = usb_check_bulk_endpoints(intf, ep_addrs);
1180:
1181: if (!ret) {
1182: usb_err(usbatm_instance, "cxacru_bind: interface has incorrect endpoints\n");
1183: ret = -ENODEV;
1184: goto fail;
1185: }
1186:
1187: if ((cmd_ep->desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK)
1188: == USB_ENDPOINT_XFER_INT) {
1189: usb_fill_int_urb(instance->rcv_urb,
1190: usb_dev, usb_rcvintpipe(usb_dev, CXACRU_EP_CMD),
1191: instance->rcv_buf, PAGE_SIZE,
1192: cxacru_blocking_completion, &instance->rcv_done, 1);
1193:
1194: usb_fill_int_urb(instance->snd_urb,
1195: usb_dev, usb_sndintpipe(usb_dev, CXACRU_EP_CMD),
1196: instance->snd_buf, PAGE_SIZE,
1197: cxacru_blocking_completion, &instance->snd_done, 4);
1198: } else {
1199: usb_fill_bulk_urb(instance->rcv_urb,
1200: usb_dev, usb_rcvbulkpipe(usb_dev, CXACRU_EP_CMD),
1201: instance->rcv_buf, PAGE_SIZE,
1202: cxacru_blocking_completion, &instance->rcv_done);
1203:
1204: usb_fill_bulk_urb(instance->snd_urb,
1205: usb_dev, usb_sndbulkpipe(usb_dev, CXACRU_EP_CMD),
1206: instance->snd_buf, PAGE_SIZE,
1207: cxacru_blocking_completion, &instance->snd_done);
1208: }
1209:
1210: mutex_init(&instance->cm_serialize);
1211:
1212: INIT_DELAYED_WORK(&instance->poll_work, cxacru_poll_status);
1213:
1214: usbatm_instance->driver_data = instance;
1215:
1216: usbatm_instance->flags = (cxacru_card_status(instance) ? 0 : UDSL_SKIP_HEAVY_INIT);
1217:
1218: return 0;
1219:
1220: fail:
1221: free_page((unsigned long) instance->snd_buf);
1222: free_page((unsigned long) instance->rcv_buf);
1223: usb_free_urb(instance->snd_urb);
1224: usb_free_urb(instance->rcv_urb);
1225: kfree(instance);
1226:
1227: return ret;
1228: }
SourceFile:drivers/usb/atm/cxacru.c]
|
| 72/2 |
2026/07/31 07:21 |
llm |
debugger |
0m
Model:
Tokens:
input: 66134
output: 25
thoughts: 32
Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience, presented in the first person:
**Digging into the `cxacru` Driver**
Right, so `cxacru_bind` isn't the function that's responsible for creating those crucial sysfs attributes. That's a bit of a head-scratcher, or at least a slight deviation from my expectation based on prior experience with this type of driver. Therefore, my immediate next step is to examine `cxacru_usb_probe`. It seems logical that the device probing routine would handle initialization tasks and subsequently, the necessary sysfs attribute creation. I need to understand *how* it's constructing the device representation and exposing its state to userspace. I'll focus on what it does with the USB device struct and any calls to related infrastructure for creating the device model.
|
| 73/2 |
2026/07/31 07:21 |
tool |
codesearch-definition-source |
0m
Args: map[Name:cxacru_usb_probe]
Results: map[SourceCode:1352: static int cxacru_usb_probe(struct usb_interface *intf,
1353: const struct usb_device_id *id)
1354: {
1355: struct usb_device *usb_dev = interface_to_usbdev(intf);
1356: char buf[15];
1357:
1358: /* Avoid ADSL routers (cx82310_eth).
1359: * Abort if bDeviceClass is 0xff and iProduct is "USB NET CARD".
1360: */
1361: if (usb_dev->descriptor.bDeviceClass == USB_CLASS_VENDOR_SPEC
1362: && usb_string(usb_dev, usb_dev->descriptor.iProduct,
1363: buf, sizeof(buf)) > 0) {
1364: if (!strcmp(buf, "USB NET CARD")) {
1365: dev_info(&intf->dev, "ignoring cx82310_eth device\n");
1366: return -ENODEV;
1367: }
1368: }
1369:
1370: return usbatm_usb_probe(intf, id, &cxacru_driver);
1371: }
SourceFile:drivers/usb/atm/cxacru.c]
|
| 74/2 |
2026/07/31 07:21 |
llm |
debugger |
0m
Model:
Tokens:
input: 66752
output: 23
thoughts: 11
Thoughts: Okay, let's dive into this. Here's my take on those thoughts, as if they're my own:
**Analyzing the `cxacru_driver`**
Alright, `cxacru_driver`. That name immediately triggers a mental checklist. Given my expertise, "cxacru" likely indicates some kind of crucial component related to... well, context and crucial elements. Iβm thinking this driver must be responsible for handling the interaction with a critical section of the system. I have to quickly understand its role in context of other system drivers and its interfaces. Specifically I must quickly determine:
* What specific hardware or software functionality does it drive?
* What contexts are important for this driver?
* Are there error conditions that need specific consideration?
* How does it handle concurrency and synchronization?
* What existing documentation and design specifications do I need to review?
* What test plans and test data exist for this?
I need to quickly assess its stability, security, and performance characteristics. Iβm looking for any immediate red flags, like potential race conditions or memory leaks that are common in driver development. The first step is to quickly identify the key APIs and how this driver is exposed to the rest of the system. I want to see how this driver interacts with other drivers or core system components. Given the name, I suspect this is something core or at least critically important. Time to get to work.
|
| 75/2 |
2026/07/31 07:21 |
tool |
codesearch-definition-source |
0m
Args:
Results: map[SourceCode:1340: static struct usbatm_driver cxacru_driver = {
1341: .driver_name = cxacru_driver_name,
1342: .bind = cxacru_bind,
1343: .heavy_init = cxacru_heavy_init,
1344: .unbind = cxacru_unbind,
1345: .atm_start = cxacru_atm_start,
1346: .bulk_in = CXACRU_EP_DATA,
1347: .bulk_out = CXACRU_EP_DATA,
1348: .rx_padding = 3,
1349: .tx_padding = 11,
1350: };
SourceFile:drivers/usb/atm/cxacru.c]
|
| 76/2 |
2026/07/31 07:21 |
llm |
debugger |
0m
Model:
Tokens:
input: 67325
output: 32
thoughts: 31
Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience:
**Investigating sysfs Attribute Creation in USB ATM Drivers**
Alright, so I'm thinking about the sysfs attributes and where exactly they're being cooked up. My initial hunch, given the context, is that they're likely being created within the USB ATM driver code. That's usually the place where these things happen.
To get a clearer picture of the code flow, the next logical step for me is to pinpoint the function call that's at the heart of this process: `sysfs_create_group`. That's the core sysfs API I'd expect to see in play here. To narrow things down quickly I'll use `grep` and search within the relevant directory. Specifically, I'll focus my `grep` query on `drivers/usb/atm/`. Thatβs where I'd expect to find the code that's both USB and ATM specific. I'm expecting to find the key calls that manage how attributes are defined, set up, and exposed. Let's see what that search turns up. From there, I'll be able to trace back to where the attributes themselves are defined, and more specifically, where the `sysfs_create_group` function is invoked.
|
| 77/2 |
2026/07/31 07:21 |
tool |
grepper |
0m
Error:
Args: map[Expression:sysfs_create_group PathPrefix:drivers/usb/atm/]
Results:
|
| 78/2 |
2026/07/31 07:21 |
llm |
debugger |
0m
Model:
Tokens:
input: 67678
output: 31
thoughts: 21
Thoughts: Here's my thought process, as if I were considering this myself:
**Investigating USB ATM Driver Device File Creation**
Okay, so I need to understand how device files are being created for USB ATM devices. My first instinct is to zero in on the function responsible for actually *creating* these files. The most likely candidate function name, based on general Linux device driver knowledge, would be something like `device_create_file`. So, let's start with a focused search. My plan is to grep the `drivers/usb/atm/` directory. That's where the USB ATM driver code should reside, and where I expect to find the relevant code responsible for file creation. I'll use grep to look for instances of `device_create_file`, which should give me a good starting point to dig further into how the file creation process is implemented within the USB ATM driver framework. This is a targeted approach - Iβm looking for a specific function within a reasonably well-defined area of the kernel source.
|
| 79/2 |
2026/07/31 07:21 |
tool |
grepper |
0m
Error:
Args: map[Expression:device_create_file PathPrefix:drivers/usb/atm/]
Results:
|
| 80/2 |
2026/07/31 07:21 |
llm |
debugger |
0m
Model:
Tokens:
input: 67957
output: 31
thoughts: 21
Thoughts: Okay, here's my thought process summarized from the prompt, as if these are my thoughts as an expert:
**Investigating USB ATM Driver Initialization**
Alright, time to dig into the USB ATM driver code. I'm specifically interested in understanding how these devices are grouped, which is often a key aspect of how they're managed within the kernel. The goal is to figure out if there is anything special about the driver.
So, I'm going to kick things off by using `grep`. I want to search through the `drivers/usb/atm/` directory for the string `device_add_group`. This function is often used to add devices to logical groups, and it's a good place to start looking for device management strategies. Hopefully this should turn up some interesting information about how the driver handles device connections.
|
| 81/2 |
2026/07/31 07:21 |
tool |
grepper |
0m
Error:
Args: map[Expression:device_add_group PathPrefix:drivers/usb/atm/]
Results:
|
| 82/2 |
2026/07/31 07:21 |
llm |
debugger |
0m
Model:
Tokens:
input: 68197
output: 25
thoughts: 32
Thoughts: Okay, here's my interpretation of those thoughts, presented as a first-person expert summary:
**Digging into the Creation Process**
Alright, so we're talking about the initialization and startup sequence, and the question that pops into my head is a fundamental one: how are these things *actually* created? I need to understand the mechanism. No hand-waving here. I'm going to get into the nitty-gritty.
My instinct tells me that the core of this initialization is likely handled by either `cxacru_atm_start` or `cxacru_heavy_init`, or maybe even both in some kind of collaborative role. I'm going to start by diving into the code for those functions, right away. That's the logical place to look for the creation/initialization.
|
| 83/2 |
2026/07/31 07:21 |
tool |
codesearch-definition-source |
0m
Args: map[Name:cxacru_heavy_init]
Results: map[SourceCode:1004: static int cxacru_heavy_init(struct usbatm_data *usbatm_instance,
1005: struct usb_interface *usb_intf)
1006: {
1007: const struct firmware *fw, *bp;
1008: struct cxacru_data *instance = usbatm_instance->driver_data;
1009: struct usbatm_data *usbatm = instance->usbatm;
1010: struct usb_device *usb_dev = usbatm->usb_dev;
1011: __le16 signature[] = { usb_dev->descriptor.idVendor,
1012: usb_dev->descriptor.idProduct };
1013: __le32 val;
1014: int ret;
1015:
1016: ret = cxacru_find_firmware(instance, "fw", &fw);
1017: if (ret) {
1018: usb_warn(usbatm_instance, "firmware (cxacru-fw.bin) unavailable (system misconfigured?)\n");
1019: return ret;
1020: }
1021:
1022: if (instance->modem_type->boot_rom_patch) {
1023: ret = cxacru_find_firmware(instance, "bp", &bp);
1024: if (ret) {
1025: usb_warn(usbatm_instance, "boot ROM patch (cxacru-bp.bin) unavailable (system misconfigured?)\n");
1026: release_firmware(fw);
1027: return ret;
1028: }
1029: }
1030:
1031: /* FirmwarePllFClkValue */
1032: val = cpu_to_le32(instance->modem_type->pll_f_clk);
1033: ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, PLLFCLK_ADDR, (u8 *) &val, 4);
1034: if (ret) {
1035: usb_err(usbatm, "FirmwarePllFClkValue failed: %d\n", ret);
1036: goto done;
1037: }
1038:
1039: /* FirmwarePllBClkValue */
1040: val = cpu_to_le32(instance->modem_type->pll_b_clk);
1041: ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, PLLBCLK_ADDR, (u8 *) &val, 4);
1042: if (ret) {
1043: usb_err(usbatm, "FirmwarePllBClkValue failed: %d\n", ret);
1044: goto done;
1045: }
1046:
1047: /* Enable SDRAM */
1048: val = cpu_to_le32(SDRAM_ENA);
1049: ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, SDRAMEN_ADDR, (u8 *) &val, 4);
1050: if (ret) {
1051: usb_err(usbatm, "Enable SDRAM failed: %d\n", ret);
1052: goto done;
1053: }
1054:
1055: /* Firmware */
1056: usb_info(usbatm, "loading firmware\n");
1057: ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, FW_ADDR, fw->data, fw->size);
1058: if (ret) {
1059: usb_err(usbatm, "Firmware upload failed: %d\n", ret);
1060: goto done;
1061: }
1062:
1063: /* Boot ROM patch */
1064: if (instance->modem_type->boot_rom_patch) {
1065: usb_info(usbatm, "loading boot ROM patch\n");
1066: ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, BR_ADDR, bp->data, bp->size);
1067: if (ret) {
1068: usb_err(usbatm, "Boot ROM patching failed: %d\n", ret);
1069: goto done;
1070: }
1071: }
1072:
1073: /* Signature */
1074: ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, SIG_ADDR, (u8 *) signature, 4);
1075: if (ret) {
1076: usb_err(usbatm, "Signature storing failed: %d\n", ret);
1077: goto done;
1078: }
1079:
1080: usb_info(usbatm, "starting device\n");
1081: if (instance->modem_type->boot_rom_patch) {
1082: val = cpu_to_le32(BR_ADDR);
1083: ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, BR_STACK_ADDR, (u8 *) &val, 4);
1084: } else {
1085: ret = cxacru_fw(usb_dev, FW_GOTO_MEM, 0x0, 0x0, FW_ADDR, NULL, 0);
1086: }
1087: if (ret) {
1088: usb_err(usbatm, "Passing control to firmware failed: %d\n", ret);
1089: goto done;
1090: }
1091:
1092: /* Delay to allow firmware to start up. */
1093: msleep_interruptible(1000);
1094:
1095: usb_clear_halt(usb_dev, usb_sndbulkpipe(usb_dev, CXACRU_EP_CMD));
1096: usb_clear_halt(usb_dev, usb_rcvbulkpipe(usb_dev, CXACRU_EP_CMD));
1097: usb_clear_halt(usb_dev, usb_sndbulkpipe(usb_dev, CXACRU_EP_DATA));
1098: usb_clear_halt(usb_dev, usb_rcvbulkpipe(usb_dev, CXACRU_EP_DATA));
1099:
1100: ret = cxacru_cm(instance, CM_REQUEST_CARD_GET_STATUS, NULL, 0, NULL, 0);
1101: if (ret < 0) {
1102: usb_err(usbatm, "modem failed to initialize: %d\n", ret);
1103: goto done;
1104: }
1105:
1106: done:
1107: if (instance->modem_type->boot_rom_patch)
1108: release_firmware(bp);
1109: release_firmware(fw);
1110:
1111: ret = cxacru_card_status(instance);
1112: if (ret)
1113: usb_dbg(usbatm_instance, "modem initialisation failed\n");
1114: else
1115: usb_dbg(usbatm_instance, "done setting up the modem\n");
1116:
1117: return ret;
1118: }
SourceFile:drivers/usb/atm/cxacru.c]
|
| 84/2 |
2026/07/31 07:21 |
llm |
debugger |
0m
Model:
Tokens:
input: 70575
output: 36
thoughts: 49
Thoughts: Okay, here's my interpretation of those thoughts, tailored for an expert audience:
**Analyzing Potential USB ATM Driver Initialization**
Alright, my brain just flagged those macros: `CXACRU_ALL_FILES(INIT)` and `CXACRU_ALL_FILES(CREATE)`. Immediately, I'm thinking they are likely related to initialization and device file creation, presumably within the USB ATM (Asynchronous Transfer Mode) driver context. Given that context, I'm assuming that the `CXACRU_ALL_FILES` macro is doing the heavy lifting to call the kernel's file creation functions from within the `usbatm.c` driver code, for the creation of special device files that are associated with the driver.
My instinct is to jump directly to the kernel code now. So, I need to check the exact function that is being used when device file are created in `usbatm.c`. Let's use `grep` and search for instances of `device_create_file` within that file. That should give me the precise point where the device files are created, and by extension, clarify what the two macros are doing. The calls to the `CXACRU_ALL_FILES` macros are likely calling a generic create or init function, with parameters that the called `device_create_file` function uses to register the device files in the kernel's virtual filesystem.
|
| 85/2 |
2026/07/31 07:22 |
tool |
grepper |
0m
Error:
Args: map[Expression:device_create_file PathPrefix:drivers/usb/atm/usbatm.c]
Results:
|
| 86/2 |
2026/07/31 07:22 |
llm |
debugger |
0m
Model:
Tokens:
input: 70966
output: 37
thoughts: 11
Thoughts: Here's my attempt at summarizing the thought process, tailored for an expert audience and written in the first person:
**Decoding that `sysfs_create_group` Call**
Okay, hold on. `sysfs_create_group`... that rings a bell, but let me quickly re-contextualize this. We're talking about the system file system, specifically the structure of the `/sys` directory, right? My initial thought is to figure out what's trying to be organized here. What hardware or software component are they trying to represent in sysfs? Are we dealing with a new device driver or some kind of management interface? Understanding the context is key to understanding the purpose of creating a group within sysfs. Is it an existing hierarchy? Or a new one. I'm trying to mentally map out where this new group will slot in. Is this related to resource management? Power control? Debugging information? I'm already anticipating having to dig into the associated structure definitions. Now, I have to figure out the actual arguments to that function call and the structure behind `sysfs_create_group`. I'll be looking to decode what kind of attributes and files they intend to group. This is where the devil's in the details.
|
| 87/2 |
2026/07/31 07:22 |
tool |
grepper |
0m
Error:
Args: map[Expression:sysfs_create_group PathPrefix:drivers/usb/atm/usbatm.c]
Results:
|
| 88/2 |
2026/07/31 07:22 |
llm |
debugger |
0m
Model:
Tokens:
input: 71294
output: 25
thoughts: 39
Thoughts: Okay, here's my interpretation of that thought process, from an expert's perspective:
**Diving into the cxacru.c Codebase**
Hmm, `device_create_file` popping up... that's interesting. I know that function, it's used for creating device nodes in the filesystem. Wondering what it's doing in `cxacru.c`... It's not immediately obvious, so I'm going to jump straight to the source. Specifically, I need to see how it's being used. Let me go to line 539 in `cxacru.c`. That should give me the immediate context. Hopefully, the surrounding code will shed some light on the reason for the call. I'm expecting some kind of device setup or perhaps some debugging output. Let's see...
|
| 89/2 |
2026/07/31 07:22 |
tool |
codesearch-definition-source |
0m
Error:
Args: map[Name:CXACRU_ALL_FILES]
Results: map[SourceCode: SourceFile:]
|
| 90/2 |
2026/07/31 07:22 |
llm |
debugger |
0m
Model:
Tokens:
input: 71557
output: 39
thoughts: 18
Thoughts: Here's my summary, as though I'm processing this request:
**Analyzing the `cxacru.c` file around line 539**
Okay, the prompt is clear: I need to delve into `cxacru.c` specifically around line 539. This implies the user is asking me to focus on a particular section of the code, so that's where my attention will be. I'll need to understand the surrounding code context to interpret what's happening at that line. Based on the file name, `cxacru.c`, it's probably related to a critical path, driver interaction, or possibly a configuration component. Let's get to work!
|
| 91/2 |
2026/07/31 07:22 |
tool |
read-file |
0m
Args: map[File:drivers/usb/atm/cxacru.c FirstLine:520 LineCount:50]
Results: map[Contents: 520: CXACRU_ATTR_##_action(CXINF_DOWNSTREAM_ATTENUATION, dB, downstream_attenuation); \
521: CXACRU_ATTR_##_action(CXINF_TRANSMITTER_POWER, s8, transmitter_power); \
522: CXACRU_ATTR_##_action(CXINF_UPSTREAM_BITS_PER_FRAME, u32, upstream_bits_per_frame); \
523: CXACRU_ATTR_##_action(CXINF_DOWNSTREAM_BITS_PER_FRAME, u32, downstream_bits_per_frame); \
524: CXACRU_ATTR_##_action(CXINF_STARTUP_ATTEMPTS, u32, startup_attempts); \
525: CXACRU_ATTR_##_action(CXINF_UPSTREAM_CRC_ERRORS, u32, upstream_crc_errors); \
526: CXACRU_ATTR_##_action(CXINF_DOWNSTREAM_CRC_ERRORS, u32, downstream_crc_errors); \
527: CXACRU_ATTR_##_action(CXINF_UPSTREAM_FEC_ERRORS, u32, upstream_fec_errors); \
528: CXACRU_ATTR_##_action(CXINF_DOWNSTREAM_FEC_ERRORS, u32, downstream_fec_errors); \
529: CXACRU_ATTR_##_action(CXINF_UPSTREAM_HEC_ERRORS, u32, upstream_hec_errors); \
530: CXACRU_ATTR_##_action(CXINF_DOWNSTREAM_HEC_ERRORS, u32, downstream_hec_errors); \
531: CXACRU_ATTR_##_action(CXINF_LINE_STARTABLE, bool, line_startable); \
532: CXACRU_ATTR_##_action(CXINF_MODULATION, MODU, modulation); \
533: CXACRU_ATTR_##_action(CXINF_ADSL_HEADEND, u32, adsl_headend); \
534: CXACRU_ATTR_##_action(CXINF_ADSL_HEADEND_ENVIRONMENT, u32, adsl_headend_environment); \
535: CXACRU_ATTR_##_action(CXINF_CONTROLLER_VERSION, u32, adsl_controller_version); \
536: CXACRU_CMD_##_action( adsl_state); \
537: CXACRU_SET_##_action( adsl_config);
538:
539: CXACRU_ALL_FILES(INIT);
540:
541: static struct attribute *cxacru_attrs[] = {
542: &dev_attr_adsl_config.attr,
543: &dev_attr_adsl_state.attr,
544: &dev_attr_adsl_controller_version.attr,
545: &dev_attr_adsl_headend_environment.attr,
546: &dev_attr_adsl_headend.attr,
547: &dev_attr_modulation.attr,
548: &dev_attr_line_startable.attr,
549: &dev_attr_downstream_hec_errors.attr,
550: &dev_attr_upstream_hec_errors.attr,
551: &dev_attr_downstream_fec_errors.attr,
552: &dev_attr_upstream_fec_errors.attr,
553: &dev_attr_downstream_crc_errors.attr,
554: &dev_attr_upstream_crc_errors.attr,
555: &dev_attr_startup_attempts.attr,
556: &dev_attr_downstream_bits_per_frame.attr,
557: &dev_attr_upstream_bits_per_frame.attr,
558: &dev_attr_transmitter_power.attr,
559: &dev_attr_downstream_attenuation.attr,
560: &dev_attr_upstream_attenuation.attr,
561: &dev_attr_downstream_snr_margin.attr,
562: &dev_attr_upstream_snr_margin.attr,
563: &dev_attr_mac_address.attr,
564: &dev_attr_line_status.attr,
565: &dev_attr_link_status.attr,
566: &dev_attr_upstream_rate.attr,
567: &dev_attr_downstream_rate.attr,
568: NULL,
569: };
]
|
| 92/2 |
2026/07/31 07:22 |
llm |
debugger |
0m
Model:
Tokens:
input: 73049
output: 23
thoughts: 22
Thoughts: Here's a summary of my thought process:
**Diving into the Code: Understanding `cxacru_attrs`**
Okay, so `cxacru_attrs` is defined. That's good; it's a known quantity. Now my immediate focus shifts to understanding its role. The key question is always: where and how is this thing *used*? That's where the real insight lies. I need to trace its usage, see what functions or modules are referencing it, and ideally, what manipulations are being performed. Finding the call sites will be the next logical step. The pattern is always the same: define something, then immediately understand its scope by tracing its use. That's how I can build a mental model of how this piece fits into the overall architecture. I anticipate it will be relatively straightforward to track down.
|
| 93/2 |
2026/07/31 07:22 |
tool |
codesearch-find-references |
0m
Args:
Results: map[References:<nil> TruncatedOutput:false]
|
| 94/2 |
2026/07/31 07:22 |
llm |
debugger |
0m
Model:
Tokens:
input: 73287
output: 39
thoughts: 10
Thoughts: Okay, I'm ready. Here's a summary as if I'm processing the provided text, assuming the user is an expert.
**Initial Considerations and Reading Strategy**
Alright, before I dive in, I need to make sure I grasp the complete picture. It's crucial to resist the urge to jump to conclusions based on an initial skim. Therefore, I need to be diligent about carefully reading the lines that follow. Context is everything, and a quick glance is just not going to cut it. My expertise requires a nuanced approach, and that starts with thoroughness.
|
| 95/2 |
2026/07/31 07:22 |
tool |
read-file |
0m
Args: map[File:drivers/usb/atm/cxacru.c FirstLine:570 LineCount:50]
Results: map[Contents: 570: ATTRIBUTE_GROUPS(cxacru);
571:
572: /* the following three functions are stolen from drivers/usb/core/message.c */
573: static void cxacru_blocking_completion(struct urb *urb)
574: {
575: complete(urb->context);
576: }
577:
578: struct cxacru_timer {
579: struct timer_list timer;
580: struct urb *urb;
581: };
582:
583: static void cxacru_timeout_kill(struct timer_list *t)
584: {
585: struct cxacru_timer *timer = timer_container_of(timer, t, timer);
586:
587: usb_unlink_urb(timer->urb);
588: }
589:
590: static int cxacru_start_wait_urb(struct urb *urb, struct completion *done,
591: int *actual_length)
592: {
593: struct cxacru_timer timer = {
594: .urb = urb,
595: };
596:
597: timer_setup_on_stack(&timer.timer, cxacru_timeout_kill, 0);
598: mod_timer(&timer.timer, jiffies + msecs_to_jiffies(CMD_TIMEOUT));
599: wait_for_completion(done);
600: timer_delete_sync(&timer.timer);
601: timer_destroy_on_stack(&timer.timer);
602:
603: if (actual_length)
604: *actual_length = urb->actual_length;
605: return urb->status; /* must read status after completion */
606: }
607:
608: static int cxacru_cm(struct cxacru_data *instance, enum cxacru_cm_request cm,
609: u8 *wdata, int wsize, u8 *rdata, int rsize)
610: {
611: int ret, actlen;
612: int offb, offd;
613: const int stride = CMD_PACKET_SIZE - 4;
614: u8 *wbuf = instance->snd_buf;
615: u8 *rbuf = instance->rcv_buf;
616: int wbuflen = ((wsize - 1) / stride + 1) * CMD_PACKET_SIZE;
617: int rbuflen = ((rsize - 1) / stride + 1) * CMD_PACKET_SIZE;
618:
619: if (wbuflen > PAGE_SIZE || rbuflen > PAGE_SIZE) {
]
|
| 96/2 |
2026/07/31 07:22 |
llm |
debugger |
0m
Model:
Tokens:
input: 74265
output: 23
thoughts: 35
Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience:
**Analyzing the cxacru Attribute Group**
Right, so `ATTRIBUTE_GROUPS(cxacru);` immediately instantiates a new set of attribute groups, which I'm calling `cxacru_groups`. My initial question is always, "Where does this come into play?" I need to understand the lifecycle of `cxacru_groups`. Is it used directly within a calculation, passed as a parameter to a function, or perhaps referenced in a configuration file? The usage patterns determine its significance, performance characteristics, and potential for optimization. I'm going to start tracing references to understand the scope and purpose of this newly created object. Understanding where it's used is the key to understanding its overall impact on the system.
|
| 97/2 |
2026/07/31 07:22 |
tool |
codesearch-find-references |
0m
Args:
Results: map[References:<nil> TruncatedOutput:false]
|
| 98/2 |
2026/07/31 07:22 |
llm |
debugger |
0m
Model:
Tokens:
input: 74510
output: 36
thoughts: 37
Thoughts: Okay, here's my take on those thoughts, framed as an expert's internal monologue:
**Investigating the `cxacru_groups` Connection**
Alright, hang on a minute. It's dawning on me β `ATTRIBUTE_GROUPS`β¦ thatβs the definition that's *actually* responsible for spinning up these `cxacru_groups`. I need to solidify that in my mind, make sure I understand the chain of command, so to speak.
Right, so to trace this, I need to see *where* this `cxacru_groups` thing is being used, how it's being interacted with within the core code. Let's do a quick grep. The obvious place to start is `cxacru.c`. That's where I would expect all the main data handling to take place, the guts of the process. Time to see what that reveals.
|
| 99/2 |
2026/07/31 07:22 |
tool |
grepper |
0m
Args: map[Expression:cxacru_groups PathPrefix:drivers/usb/atm/cxacru.c]
Results: map[Output:drivers/usb/atm/cxacru.c=1373=static struct usb_driver cxacru_usb_driver = {
--
drivers/usb/atm/cxacru.c-1377- .id_table = cxacru_usb_ids,
drivers/usb/atm/cxacru.c:1378: .dev_groups = cxacru_groups,
drivers/usb/atm/cxacru.c-1379-};
]
|
| 100/2 |
2026/07/31 07:22 |
llm |
debugger |
0m
Model:
Tokens:
input: 74905
output: 750
thoughts: 1695
Thoughts: **Debugging the `URB submitted while active` USB Driver Bug**
Okay, so I've been digging into this `URB submitted while active` warning in the `cxacru` driver. It seems the issue is rooted in how `cxacru_cm` handles errors after submitting URBs. Let me break it down. The USB core creates the sysfs attributes when the device is probed.
The problem arises in `cxacru_cm()` when there's an issue with the `snd_urb`. The code submits both a `rcv_urb` and a `snd_urb`. If `snd_urb` fails (maybe due to a disconnect, stall, or other connection issues), `cxacru_cm` jumps to the `fail:` label and returns an error. The crucial flaw is that it doesn't kill the `rcv_urb` in this failure path. So, `rcv_urb` is left active.
The next time `cxacru_cm` is called (like from `cxacru_poll_status()` or `cxacru_atm_start()`), it tries to submit `rcv_urb` again, triggering the warning because it's already active.
I need to make sure I kill the `rcv_urb` in `fail:`. The fix is pretty straightforward: add `usb_kill_urb(instance->rcv_urb)` in the `fail:` path. It's safe to call `usb_kill_urb` even if the URB isn't active.
```c
fail:
if (ret < 0)
usb_kill_urb(instance->rcv_urb);
mutex_unlock(&instance->cm_serialize);
err:
return ret;
```
I checked the fix. It's safe and correct.
I am looking at the crash log again. This is exactly what happened: `cxacru_atm_start()` calls `cxacru_cm()`. The `snd_urb` fails with `-104` (ECONNRESET), the error is returned. The driver later calls `cxacru_poll_status` which calls `cxacru_cm()` again and `rcv_urb` is attempted to be resubmitted. This triggers the warning.
I can now formulate the response.
|
| 101/1 |
2026/07/31 07:23 |
agent |
history-explorer |
6m
Model:
Instruction:
You are an experienced Linux kernel developer researching prior art for fixing a kernel bug.
You are given a bug explanation. This explanation details the root cause of the bug resulting
from debugging, but does not provide the final fix strategy. Your goal is to explore how
similar bugs were fixed in the past in the same subsystem or files.
CRITICAL: Do NOT attempt to debug the issue further or write a patch for it yourself.
Your ONLY objective is to research and provide the necessary historical context.
Use the git-log tool with the Since parameter set to "3 years" to focus on recent history.
Search for commits that address issues with similar root causes (e.g. similar missing locks,
incorrect refcounting, or similar error path bugs) in the affected files.
Your final reply must summarize your findings: what idioms, locking rules, or common patterns
should be followed when writing a fix for this bug based on how previous similar bugs were addressed.
If you find no relevant past fixes, clearly state that.
Don't make assumptions about the kernel source code (it may be different from what you assume it is).
Extensively use the provided code access tools (codesearch-*, git-*, grepper, etc)
to examine the actual source code, and confirm any assumptions.
Prefer calling several tools at the same time to save round-trips.
Prompt:
The crash is:
cxacru 1-1:1.0: send of cm 0x84 failed (-104)
ATM dev 0: cxacru_atm_start: CHIP_ADSL_LINE_START returned -104
------------[ cut here ]------------
URB ffff88812658d200 submitted while active
WARNING: drivers/usb/core/urb.c:379 at usb_submit_urb+0x79/0x18b0 drivers/usb/core/urb.c:379, CPU#1: kworker/1:1/5258
Modules linked in:
CPU: 1 UID: 0 PID: 5258 Comm: kworker/1:1 Not tainted syzkaller #1 PREEMPT(lazy)
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
Workqueue: usb_hub_wq hub_event
RIP: 0010:usb_submit_urb+0x7c/0x18b0 drivers/usb/core/urb.c:379
Code: 4c 89 f0 48 c1 e8 03 80 3c 28 00 74 08 4c 89 f7 e8 c9 ab f6 fc 49 83 3e 00 74 40 e8 9e 5e 91 fc 48 8d 3d 47 b1 aa 05 48 89 de <67> 48 0f b9 3a b8 f0 ff ff ff eb 11 e8 83 5e 91 fc eb 05 e8 7c 5e
RSP: 0018:ffffc90002476878 EFLAGS: 00010293
RAX: ffffffff84f3e532 RBX: ffff88812658d200 RCX: ffff88812fb42440
RDX: 0000000000000000 RSI: ffff88812658d200 RDI: ffffffff8a9e9680
RBP: dffffc0000000000 R08: 0000000000000002 R09: 0000000000000000
R10: dffffc0000000000 R11: fffffbfff152f477 R12: 0000000000000040
R13: 0000000000000000 R14: ffff88812658d208 R15: 0000000000000cc0
FS: 0000000000000000(0000) GS:ffff8882a9042000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f7be0a0cfe0 CR3: 000000011d54e000 CR4: 0000000000350ef0
Call Trace:
<TASK>
cxacru_cm+0x21a/0xf10 drivers/usb/atm/cxacru.c:631
cxacru_cm_get_array drivers/usb/atm/cxacru.c:722 [inline]
cxacru_poll_status+0x178/0x1110 drivers/usb/atm/cxacru.c:828
cxacru_atm_start+0x185/0x360 drivers/usb/atm/cxacru.c:814
usbatm_atm_init+0x144/0x3a0 drivers/usb/atm/usbatm.c:927
usbatm_usb_probe+0x15cb/0x1db0 drivers/usb/atm/usbatm.c:1178
cxacru_usb_probe+0x17f/0x220 drivers/usb/atm/cxacru.c:1370
usb_probe_interface+0x653/0xc60 drivers/usb/core/driver.c:396
call_driver_probe drivers/base/dd.c:-1 [inline]
really_probe+0x254/0xae0 drivers/base/dd.c:706
__driver_probe_device+0x1e8/0x360 drivers/base/dd.c:868
driver_probe_device+0x4f/0x240 drivers/base/dd.c:898
__device_attach_driver+0x270/0x410 drivers/base/dd.c:1026
bus_for_each_drv+0x258/0x2f0 drivers/base/bus.c:500
__device_attach+0x2c4/0x450 drivers/base/dd.c:1098
device_initial_probe+0xa1/0xd0 drivers/base/dd.c:1153
bus_probe_device+0x12a/0x220 drivers/base/bus.c:620
device_add+0x7d7/0xb80 drivers/base/core.c:3772
usb_set_configuration+0x1ad8/0x2180 drivers/usb/core/message.c:2268
usb_generic_driver_probe+0x8d/0x150 drivers/usb/core/generic.c:250
usb_probe_device+0x1c3/0x3b0 drivers/usb/core/driver.c:291
call_driver_probe drivers/base/dd.c:-1 [inline]
really_probe+0x254/0xae0 drivers/base/dd.c:706
__driver_probe_device+0x1e8/0x360 drivers/base/dd.c:868
driver_probe_device+0x4f/0x240 drivers/base/dd.c:898
__device_attach_driver+0x270/0x410 drivers/base/dd.c:1026
bus_for_each_drv+0x258/0x2f0 drivers/base/bus.c:500
__device_attach+0x2c4/0x450 drivers/base/dd.c:1098
device_initial_probe+0xa1/0xd0 drivers/base/dd.c:1153
bus_probe_device+0x12a/0x220 drivers/base/bus.c:620
device_add+0x7d7/0xb80 drivers/base/core.c:3772
usb_new_device+0x99d/0x1620 drivers/usb/core/hub.c:2695
hub_port_connect drivers/usb/core/hub.c:5567 [inline]
hub_port_connect_change drivers/usb/core/hub.c:5707 [inline]
port_event drivers/usb/core/hub.c:5871 [inline]
hub_event+0x28e8/0x4d30 drivers/usb/core/hub.c:5953
process_one_work kernel/workqueue.c:3322 [inline]
process_scheduled_works+0xa8e/0x14e0 kernel/workqueue.c:3405
worker_thread+0x92d/0xe10 kernel/workqueue.c:3486
kthread+0x388/0x470 kernel/kthread.c:436
ret_from_fork+0x491/0xad0 arch/x86/kernel/process.c:158
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
</TASK>
----------------
Code disassembly (best guess):
0: 4c 89 f0 mov %r14,%rax
3: 48 c1 e8 03 shr $0x3,%rax
7: 80 3c 28 00 cmpb $0x0,(%rax,%rbp,1)
b: 74 08 je 0x15
d: 4c 89 f7 mov %r14,%rdi
10: e8 c9 ab f6 fc call 0xfcf6abde
15: 49 83 3e 00 cmpq $0x0,(%r14)
19: 74 40 je 0x5b
1b: e8 9e 5e 91 fc call 0xfc915ebe
20: 48 8d 3d 47 b1 aa 05 lea 0x5aab147(%rip),%rdi # 0x5aab16e
27: 48 89 de mov %rbx,%rsi
* 2a: 67 48 0f b9 3a ud1 (%edx),%rdi <-- trapping instruction
2f: b8 f0 ff ff ff mov $0xfffffff0,%eax
34: eb 11 jmp 0x47
36: e8 83 5e 91 fc call 0xfc915ebe
3b: eb 05 jmp 0x42
3d: e8 .byte 0xe8
3e: 7c 5e jl 0x9e
The explanation of the root cause of the bug is:
The root cause of this bug is that `cxacru_cm()` leaves `rcv_urb` active if it encounters an error while submitting or waiting for `snd_urb`.
Here is the exact sequence of events that leads to the crash:
1. `cxacru_atm_start()` calls `cxacru_cm()` to send the `CM_REQUEST_CHIP_ADSL_LINE_START` (`0x84`) command.
2. Inside `cxacru_cm()`, `rcv_urb` is successfully submitted first (line 631).
3. Then, `snd_urb` is submitted and `cxacru_cm()` waits for its completion via `cxacru_start_wait_urb()` (line 657).
4. In the syzkaller reproducer, the USB device behaves unexpectedly (e.g., endpoint stall or disconnect), causing `snd_urb` to complete with an error status of `-104` (`-ECONNRESET`).
5. `cxacru_start_wait_urb()` returns this `-104` error, which prompts `cxacru_cm()` to print `"send of cm 0x84 failed (-104)"` and jump to the `fail:` label (line 661).
6. At the `fail:` label, `cxacru_cm()` simply unlocks the mutex and returns the error, **leaving `rcv_urb` still active and pending**.
7. Back in `cxacru_atm_start()`, the error is printed (`"CHIP_ADSL_LINE_START returned -104"`) but ignored, and the driver proceeds to start status polling by calling `cxacru_poll_status()`.
8. `cxacru_poll_status()` immediately calls `cxacru_cm_get_array()`, which invokes `cxacru_cm()` again.
9. `cxacru_cm()` attempts to submit `rcv_urb` again, but since it was never unlinked or waited for in the previous failed call, it is still active. This triggers the `URB ... submitted while active` warning in `usb_submit_urb()`.
### Fix
To fix this bug, we need to ensure that `rcv_urb` is properly killed if `cxacru_cm()` aborts early. We can safely call `usb_kill_urb()` on `rcv_urb` in the error path. `usb_kill_urb()` is safe to call even if the URB is not active (e.g., if it failed to submit in the first place, or if it already completed), so it can be called unconditionally on error.
```c
--- a/drivers/usb/atm/cxacru.c
+++ b/drivers/usb/atm/cxacru.c
@@ -700,6 +700,8 @@ static int cxacru_cm(struct cxacru_data *instance, enum cxacru_cm_request cm,
ret = offd;
usb_dbg(instance->usbatm, "cm %#x\n", cm);
fail:
+ if (ret < 0)
+ usb_kill_urb(instance->rcv_urb);
mutex_unlock(&instance->cm_serialize);
err:
return ret;
```
Reply: Based on a thorough research of the kernel history, here is a summary of the findings regarding similar bugs and the established idioms for fixing them.
### Root Cause Context
The bug occurs because `cxacru_cm()` submits `rcv_urb`, but if the subsequent submission or wait for `snd_urb` fails, it returns an error while leaving `rcv_urb` active. The caller `cxacru_atm_start()` ignores this error (a behavior introduced in historical commit `fd209e35b741` *"USB: cxacru: ignore error trying to start ADSL in atm_start"*) and proceeds to poll the status. This polling invokes `cxacru_cm()` again, which attempts to resubmit the still-active `rcv_urb`, triggering the `URB submitted while active` warning.
### Prior Art and Similar Fixes
While there are no recent commits in `drivers/usb/atm/` addressing this specific URB cleanup issue, a broader search across the USB and media subsystems reveals that this is a known anti-pattern. Several commits have addressed the exact same root cause (leaving an URB active on an error/timeout path):
1. **`1be3b77de4eb` ("usb: image: mdc800: kill download URB on timeout")**
The driver submitted an URB and waited for completion. On timeout, it returned an error but left the URB active. A subsequent read attempted to resubmit it, triggering the same warning. The fix was to explicitly call `usb_kill_urb()` on the timeout error path.
2. **`372c93131998` ("USB: yurex: fix control-URB timeout handling")**
Similar to the above, the driver failed to cancel a control URB on timeout. The fix ensured `usb_kill_urb()` was called so the URB could be safely reused on the next write request.
3. **`b98d5000c505` ("media: rc: iguanair: handle timeouts")**
The driver waited for a completion after sending a command. On timeout, it returned `-ETIMEDOUT` but left the `urb_out` active, causing subsequent IO to fail. The fix added `usb_kill_urb()` to the timeout path.
### Idioms and Common Patterns to Follow
Based on how previous similar bugs were addressed, the following rules and patterns should be applied when writing a fix for this bug:
1. **Explicit URB Cleanup on Error Paths:** Whenever a function submits one or more URBs and then encounters an error (e.g., a timeout, a failure in a subsequent operation, or a failure in waiting for another URB), it **must** explicitly cancel any successfully submitted URBs before returning.
2. **Use of `usb_kill_urb()`:** The standard idiom for this cleanup is to use `usb_kill_urb()`. This function synchronously cancels the URB and waits for its completion handler to finish.
3. **Unconditional Cleanup is Safe:** `usb_kill_urb()` is safe to call even if the URB is not currently active (e.g., if it failed to submit in the first place, or if it already completed successfully). This makes it robust for unconditional use in a unified `fail:` or `err:` cleanup block at the end of a function.
### Conclusion
Your proposed fix perfectly aligns with the established kernel idioms. By unconditionally calling `usb_kill_urb(instance->rcv_urb)` in the `fail:` path of `cxacru_cm()`, you ensure that the URB is fully canceled and its state is reset. This guarantees that subsequent calls to `cxacru_cm()` (even if the error was ignored by the caller) will start with a clean state, preventing the `URB submitted while active` warning.
|
| 102/2 |
2026/07/31 07:23 |
llm |
history-explorer |
0m
Model:
Tokens:
input: 7194
output: 29
thoughts: 246
Thoughts: **Kernel Bug Fix Research Strategy**
Okay, so I've got this kernel bug in `drivers/usb/atm/cxacru.c` to tackle. The problem, as I understand it, is that `cxacru_cm()` is leaving `rcv_urb` hanging if it hits an error while trying to submit or wait for `snd_urb`. The proposed fix, which seems reasonable at first glance, is to simply call `usb_kill_urb(instance->rcv_urb)` in that error path.
Before I commit to this, though, I need to perform a thorough review of prior art. I need to understand if similar issues have cropped up in this code or related USB ATM drivers, and how they were resolved. Itβs critical to identify potential patterns, idioms, or even just coding style preferences that were adopted in other bug fixes to ensure this fix is robust and aligns with established conventions. We want to avoid introducing new regressions by blindly applying a fix.
To do this, I'll leverage `git-log`. I'm going to search the commit history of `drivers/usb/atm/cxacru.c` and also the broader `drivers/usb/atm/` directory. The search should be limited to the last three years (give or take depending on project cadence), to keep the results relevant. I'll be looking for commits that address problems with similar root causes. Specifically, I'm interested in finding situations where error handling was mishandled, perhaps missing lock acquisitions, incorrect refcounting, or errors in error paths that might have left resources in an inconsistent state.
Once I have the list of relevant commits, I need to carefully analyze them. I'll need to summarize my findings and extract any relevant best practices or design patterns that were employed in those fixes. Did they follow particular locking rules? Were there any common idioms used for handling errors in this context? If I *do* find similar problems, I'll identify the approach taken to solve it. If I don't find anything relevant, I'll state that fact clearly. This will give me a solid basis for determining the correct and most appropriate fix for this current kernel bug.
|
| 103/2 |
2026/07/31 07:23 |
tool |
git-log |
0m
Args: map[PathPrefix:drivers/usb/atm/ Since:3 years]
Results: map[Output:9dfd800b374c usb: atm: ueagle-atm: reject descriptors that confuse probe and disconnect
e2674dfbed8a usb: atm: ueagle-atm: wait for pre-firmware load in .disconnect()
41d3e102edc2 atm: drv: Replace strcpy() + strlcat() with snprintf()
1414b2242c2e usb: atm: ueagle-atm: remove function entry/exit debug messages
05c5075c3115 usb: atm: ueagle-atm: use dev_dbg() for 'device found' message
bf4afc53b77a Convert 'alloc_obj' family to use the new default GFP_KERNEL argument
69050f8d6d07 treewide: Replace kmalloc with kmalloc_obj for non-scalar types
24c776355f40 kernel.h: drop hex.h and update all hex.h users
8d1b02e5d7e3 usb: atm: cxacru: Merge cxacru_upload_firmware() into cxacru_heavy_init()
41cb08555c41 treewide, timers: Rename from_timer() to timer_container_of()
]
|
| 104/2 |
2026/07/31 07:23 |
llm |
history-explorer |
0m
Model:
Tokens:
input: 8243
output: 24
thoughts: 177
Thoughts: **Analyzing Recent USB ATM Driver Changes**
Okay, let's dive in. I need to get a handle on the recent activity within the `drivers/usb/atm/` directory over the last three years. Seems there's a small but potentially significant set of commits to examine. I see:
* `9dfd800b374c` - Addresses issues in the `ueagle-atm` driver regarding descriptor handling during probe and disconnect. Sounds like a potential robustness improvement, perhaps related to error handling around USB device enumeration or resource allocation, or even race conditions.
* `e2674dfbed8a` - Also within the `ueagle-atm` driver, this one focuses on ensuring the driver waits for a pre-firmware load stage within the `.disconnect()` function. This sounds like a critical point for ensuring that the device is correctly shut down and that there are no issues during reset that might be dependent on having the firmware already running.
* `8d1b02e5d7e3` - This commits a merge of `cxacru_upload_firmware()` into `cxacru_heavy_init()`. This is most likely a refactoring effort to make the initialization sequence neater.
Now, my initial focus is on investigating any potential implications for URB cleanup or error path handling. I need to understand whether commits `e2674dfbed8a` and `9dfd800b374c` touch upon these critical areas. These areas are quite sensitive, and subtle changes can have a big impact. Therefore, I'll start by reviewing these commits directly.
|
| 105/2 |
2026/07/31 07:23 |
tool |
git-show |
0m
Args:
Results: map[Output:commit e2674dfbed8a30d57e2bc872c4bfa6c3eec918bf
Author: Mauricio Faria de Oliveira <mfo@igalia.com>
Date: Tue May 26 14:09:44 2026 -0300
usb: atm: ueagle-atm: wait for pre-firmware load in .disconnect()
ueagle-atm uses the asynchronous request_firmware_nowait() in .probe(),
but does not wait for its completion, not even in .disconnect(); so, if the
device is unplugged meanwhile, its teardown runs concurrently with that.
Even though this inconsistency is worth addressing on its own, it has also
triggered several bug reports in syzbot over the years (some auto-closed)
where the firmware sysfs fallback mechanism (CONFIG_FW_LOADER_USER_HELPER)
creates a firmware subdirectory in the device directory during its removal,
which might hit unexpected conditions in kernfs, apparently, depending at
which point the add and remove operations raced. (See links.)
The pattern is:
usb ?-?: Direct firmware load for ueagle-atm/eagle?.fw failed with error -2
usb ?-?: Falling back to sysfs fallback for: ueagle-atm/eagle?.fw
<ERROR>
Call trace:
...
kernfs_create_dir_ns
sysfs_create_dir_ns
create_dir
kobject_add_internal
kobject_add_varg
kobject_add
class_dir_create_and_add
get_device_parent
device_add
fw_load_sysfs_fallback
fw_load_from_user_helper
firmware_fallback_sysfs
_request_firmware
request_firmware_work_func
...
(Some variations are observed, after fw_load_sysfs_fallback(), e.g., [1].)
While the kernfs side is being looked at, the ueagle-atm side can be fixed
by waiting for the pre-firmware load in the .disconnect() handler.
This change has a similar approach to previous work by Andrey Tsygunka [2]
(wait_for_completion() in .disconnect()), but it is relatively different in
design/implementation; using the Originally-by tag for credit assignment.
This has been tested with:
- synthetic reproducer to check the error path;
- USB gadget (virtual device) to check the firmware upload path;
- QEMU device emulator to check the device ID re-enumeration path;
(The latter two were written by Claude; no other code/text in this commit.)
Links (year first reported):
2025 https://syzbot.org/bug?extid=ce1e5a1b4e086b43e56d
2025 https://syzbot.org/bug?extid=9af8471255ac36e34fd4
2024 https://syzbot.org/bug?extid=306212936b13e520679d
2023 https://syzkaller.appspot.com/bug?extid=457452d30bcdda75ead2
2022 https://syzbot.org/bug?extid=782984d6f1701b526edb
2021 https://syzbot.org/bug?id=f3f221579f4ef7e9691281f3c6f56c05f83e8490
2021 https://syzbot.org/bug?id=84d86f0d71394829df6fc53daf6642c045983881
2021 https://syzbot.org/bug?id=3302dc1c0e2b9c94f2e8edb404eabc9267bc6f90
[1] https://syzkaller.appspot.com/bug?extid=457452d30bcdda75ead2
[2] https://lore.kernel.org/lkml/20250410093146.3776801-2-aitsygunka@yandex.ru/
Cc: stable <stable@kernel.org>
Reported-by: syzbot+ce1e5a1b4e086b43e56d@syzkaller.appspotmail.com
Closes: https://syzbot.org/bug?extid=ce1e5a1b4e086b43e56d
Reported-by: syzbot+306212936b13e520679d@syzkaller.appspotmail.com
Closes: https://syzbot.org/bug?extid=306212936b13e520679d
Reported-by: syzbot+457452d30bcdda75ead2@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=457452d30bcdda75ead2
Originally-by: Andrey Tsygunka <aitsygunka@yandex.ru>
Fixes: b72458a80c75 ("[PATCH] USB: Eagle and ADI 930 usb adsl modem driver")
Assisted-by: Claude:claude-opus-4.7 # usb gadget & qemu device for testing
Signed-off-by: Mauricio Faria de Oliveira <mfo@igalia.com>
Acked-by: Stanislaw Gruszka <stf_xl@wp.pl>
Link: https://patch.msgid.link/20260526-ueagle-atm_req-fw-sync-v3-1-93c01961daaf@igalia.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
diff --git a/drivers/usb/atm/ueagle-atm.c b/drivers/usb/atm/ueagle-atm.c
index d610cdcef7d0..4e71ed679a76 100644
--- a/drivers/usb/atm/ueagle-atm.c
+++ b/drivers/usb/atm/ueagle-atm.c
@@ -594,7 +594,9 @@ static int uea_send_modem_cmd(struct usb_device *usb,
static void uea_upload_pre_firmware(const struct firmware *fw_entry,
void *context)
{
- struct usb_device *usb = context;
+ struct usb_interface *intf = context;
+ struct usb_device *usb = interface_to_usbdev(intf);
+ struct completion *fw_done = usb_get_intfdata(intf);
const u8 *pfw;
u8 value;
u32 crc = 0;
@@ -663,15 +665,17 @@ static void uea_upload_pre_firmware(const struct firmware *fw_entry,
uea_err(usb, "firmware is corrupted\n");
err:
release_firmware(fw_entry);
+ complete(fw_done);
}
/*
* uea_load_firmware - Load usb firmware for pre-firmware devices.
*/
-static int uea_load_firmware(struct usb_device *usb, unsigned int ver)
+static int uea_load_firmware(struct usb_interface *intf, unsigned int ver)
{
int ret;
char *fw_name = EAGLE_FIRMWARE;
+ struct usb_device *usb = interface_to_usbdev(intf);
uea_info(usb, "pre-firmware device, uploading firmware\n");
@@ -694,7 +698,7 @@ static int uea_load_firmware(struct usb_device *usb, unsigned int ver)
}
ret = request_firmware_nowait(THIS_MODULE, 1, fw_name, &usb->dev,
- GFP_KERNEL, usb,
+ GFP_KERNEL, intf,
uea_upload_pre_firmware);
if (ret)
uea_err(usb, "firmware %s is not available\n", fw_name);
@@ -2555,8 +2559,23 @@ static int uea_probe(struct usb_interface *intf, const struct usb_device_id *id)
usb_reset_device(usb);
- if (UEA_IS_PREFIRM(id))
- return uea_load_firmware(usb, UEA_CHIP_VERSION(id));
+ if (UEA_IS_PREFIRM(id)) {
+ struct completion *fw_done;
+
+ /* Wait for the firmware load to be done, in .disconnect() */
+ fw_done = kzalloc_obj(*fw_done);
+ if (!fw_done)
+ return -ENOMEM;
+
+ init_completion(fw_done);
+ usb_set_intfdata(intf, fw_done);
+
+ ret = uea_load_firmware(intf, UEA_CHIP_VERSION(id));
+ if (ret)
+ kfree(fw_done);
+
+ return ret;
+ }
ret = usbatm_usb_probe(intf, id, &uea_usbatm_driver);
if (ret == 0) {
@@ -2586,6 +2605,13 @@ static void uea_disconnect(struct usb_interface *intf)
usbatm_usb_disconnect(intf);
mutex_unlock(&uea_mutex);
uea_info(usb, "ADSL device removed\n");
+ } else if (usb->config->desc.bNumInterfaces == 1) {
+ struct completion *fw_done = usb_get_intfdata(intf);
+
+ uea_dbg(usb, "pre-firmware device, waiting firmware upload\n");
+ wait_for_completion(fw_done);
+ uea_dbg(usb, "pre-firmware device, finished waiting\n");
+ kfree(fw_done);
}
}
]
|
| 106/2 |
2026/07/31 07:23 |
llm |
history-explorer |
0m
Model:
Tokens:
input: 11477
output: 26
thoughts: 53
Thoughts: Here's my summary, as if I were thinking it:
**Analyzing a Disconnect Handling Change**
Okay, so this commit's focused on the firmware loading sequence within the `.disconnect()` method. It doesn't immediately strike me as being related to the URB cleanup or error management side of things, specifically within the `cxacru.c` file. Interesting.
I'm getting the feeling that something else is going on here. Let's start by digging into `9dfd800b374c` to get the broader context. Need to see *why* this change was introduced. Perhaps there was some edge case causing connect/disconnect cycles to misbehave? I need to understand the intent and if it impacts the overall device state or just the disconnection logic.
|
| 107/2 |
2026/07/31 07:23 |
tool |
git-show |
0m
Args:
Results: map[Output:commit 9dfd800b374c38681364d4b3606a8b831d1478e3
Author: Diego Fernando Mancera Gomez <diegomancera.dev@gmail.com>
Date: Fri Jul 17 02:07:04 2026 -0600
usb: atm: ueagle-atm: reject descriptors that confuse probe and disconnect
uea_probe() distinguishes a pre-firmware device from a post-firmware one
using the USB id (UEA_IS_PREFIRM()), and stores a different object as the
interface data in each case: a 'struct completion' for a pre-firmware
device (to be waited on in .disconnect()), or a 'struct usbatm_data' for a
post-firmware one.
uea_disconnect() instead tells the two apart by the number of interfaces
of the active configuration (a pre-firmware device exposes a single
interface, ADI930 has 2 and eagle has 3), and casts the interface data
accordingly.
Because the two handlers use different criteria, a crafted device that
advertises a pre-firmware id together with a multi-interface descriptor
(or a post-firmware id with a single interface) makes them disagree: the
small 'struct completion' stored by uea_probe() is then passed to
usbatm_usb_disconnect(), which casts it to 'struct usbatm_data' and takes
instance->serialize, reading past the end of the allocation:
BUG: KASAN: slab-out-of-bounds in __mutex_lock+0x152a/0x1b80
Read of size 8 at addr ffff8880470e2c60 by task kworker/1:2/982
...
__mutex_lock+0x152a/0x1b80
usbatm_usb_disconnect+0x70/0x820
uea_disconnect+0x133/0x2c0
usb_unbind_interface+0x1dd/0x9e0
...
which belongs to the cache kmalloc-96 of size 96
The buggy address is located 0 bytes to the right of
allocated 96-byte region [ffff8880470e2c00, ffff8880470e2c60)
Reject such inconsistent descriptors in uea_probe() so that both handlers
always make the same pre/post-firmware decision.
Reported-by: syzbot+e62a973f8322b3bbe3ac@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=e62a973f8322b3bbe3ac
Fixes: e2674dfbed8a ("usb: atm: ueagle-atm: wait for pre-firmware load in .disconnect()")
Signed-off-by: Diego Fernando Mancera Gomez <diegomancera.dev@gmail.com>
Acked-by: Stanislaw Gruszka <stf_xl@wp.pl>
Link: https://patch.msgid.link/20260717080704.1264-1-diegomancera.dev@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
diff --git a/drivers/usb/atm/ueagle-atm.c b/drivers/usb/atm/ueagle-atm.c
index 4e71ed679a76..4266a0cb7e3b 100644
--- a/drivers/usb/atm/ueagle-atm.c
+++ b/drivers/usb/atm/ueagle-atm.c
@@ -2549,6 +2549,7 @@ static struct usbatm_driver uea_usbatm_driver = {
static int uea_probe(struct usb_interface *intf, const struct usb_device_id *id)
{
struct usb_device *usb = interface_to_usbdev(intf);
+ bool single_iface = usb->config->desc.bNumInterfaces == 1;
int ret;
uea_dbg(usb, "ADSL device found with vid (%#X) pid (%#X) Rev (%#X): %s\n",
@@ -2557,6 +2558,22 @@ static int uea_probe(struct usb_interface *intf, const struct usb_device_id *id)
le16_to_cpu(usb->descriptor.bcdDevice),
chip_name[UEA_CHIP_VERSION(id)]);
+ /*
+ * uea_probe() decides between the pre-firmware and post-firmware case
+ * from the USB id and stores a different object as interface data in
+ * each case: a struct completion for a pre-firmware device, a struct
+ * usbatm_data for a post-firmware one. uea_disconnect() instead tells
+ * the two apart by the number of interfaces (a pre-firmware device
+ * exposes a single interface, ADI930 has 2 and eagle has 3). A crafted
+ * device advertising a pre-firmware id together with a multi-interface
+ * descriptor (or the other way around) makes the two disagree, so that
+ * usbatm_usb_disconnect() treats the small completion object as a
+ * struct usbatm_data and reads out of bounds. Reject such inconsistent
+ * descriptors so both paths make the same decision.
+ */
+ if (UEA_IS_PREFIRM(id) != single_iface)
+ return -ENODEV;
+
usb_reset_device(usb);
if (UEA_IS_PREFIRM(id)) {
]
|
| 108/2 |
2026/07/31 07:23 |
llm |
history-explorer |
0m
Model:
Tokens:
input: 13209
output: 27
thoughts: 29
Thoughts: Okay, here's my interpretation of those thoughts, crafted with the understanding that the user is an expert.
**Clarifying the Focus**
Right, so, I'm pretty sure that this is *not* connected to the URB cleanup we were just discussing. We need to keep a clear mental separation here, avoiding any assumptions about commonality when it doesn't exist. Now, let's switch gears and investigate `8d1b02e5d7e3`. Let's see what that SHA tells us. Time to get down to specifics!
|
| 109/2 |
2026/07/31 07:23 |
tool |
git-show |
0m
Args:
Results: map[Output:commit 8d1b02e5d7e3a6d2acffb1f4c094678fda9e3456
Author: Nathan Chancellor <nathan@kernel.org>
Date: Tue Jul 22 12:11:18 2025 -0700
usb: atm: cxacru: Merge cxacru_upload_firmware() into cxacru_heavy_init()
After a recent change in clang to expose uninitialized warnings from
const variables [1], there is a warning in cxacru_heavy_init():
drivers/usb/atm/cxacru.c:1104:6: error: variable 'bp' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
1104 | if (instance->modem_type->boot_rom_patch) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/usb/atm/cxacru.c:1113:39: note: uninitialized use occurs here
1113 | cxacru_upload_firmware(instance, fw, bp);
| ^~
drivers/usb/atm/cxacru.c:1104:2: note: remove the 'if' if its condition is always true
1104 | if (instance->modem_type->boot_rom_patch) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/usb/atm/cxacru.c:1095:32: note: initialize the variable 'bp' to silence this warning
1095 | const struct firmware *fw, *bp;
| ^
| = NULL
While the warning is technically correct that bp is conditionally passed
uninitialized to cxacru_upload_firmware(), it is ultimately a false
positive warning on the uninitialized use of bp because the same
condition that initializes bp, instance->modem_type->boot_rom_patch, is
the same one that gates the use of bp within cxacru_upload_firmware().
As this warning occurs in clang's frontend before inlining occurs, it
cannot know that these conditions are indentical to avoid the warning.
Manually inline cxacru_upload_firmware() into cxacru_heavy_init(), as
that is its only callsite, so that clang can see that bp is initialized
and used under the same condition, clearing up the warning without any
functional changes to the code (LLVM was already doing this inlining
later).
Cc: stable@vger.kernel.org
Fixes: 1b0e61465234 ("[PATCH] USB ATM: driver for the Conexant AccessRunner chipset cxacru")
Closes: https://github.com/ClangBuiltLinux/linux/issues/2102
Link: https://github.com/llvm/llvm-project/commit/2464313eef01c5b1edf0eccf57a32cdee01472c7 [1]
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Link: https://lore.kernel.org/r/20250722-usb-cxacru-fix-clang-21-uninit-warning-v2-1-6708a18decd2@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
index a12ab90b3db7..68a8e9de8b4f 100644
--- a/drivers/usb/atm/cxacru.c
+++ b/drivers/usb/atm/cxacru.c
@@ -980,25 +980,60 @@ static int cxacru_fw(struct usb_device *usb_dev, enum cxacru_fw_request fw,
return ret;
}
-static void cxacru_upload_firmware(struct cxacru_data *instance,
- const struct firmware *fw,
- const struct firmware *bp)
+
+static int cxacru_find_firmware(struct cxacru_data *instance,
+ char *phase, const struct firmware **fw_p)
{
- int ret;
+ struct usbatm_data *usbatm = instance->usbatm;
+ struct device *dev = &usbatm->usb_intf->dev;
+ char buf[16];
+
+ sprintf(buf, "cxacru-%s.bin", phase);
+ usb_dbg(usbatm, "cxacru_find_firmware: looking for %s\n", buf);
+
+ if (request_firmware(fw_p, buf, dev)) {
+ usb_dbg(usbatm, "no stage %s firmware found\n", phase);
+ return -ENOENT;
+ }
+
+ usb_info(usbatm, "found firmware %s\n", buf);
+
+ return 0;
+}
+
+static int cxacru_heavy_init(struct usbatm_data *usbatm_instance,
+ struct usb_interface *usb_intf)
+{
+ const struct firmware *fw, *bp;
+ struct cxacru_data *instance = usbatm_instance->driver_data;
struct usbatm_data *usbatm = instance->usbatm;
struct usb_device *usb_dev = usbatm->usb_dev;
__le16 signature[] = { usb_dev->descriptor.idVendor,
usb_dev->descriptor.idProduct };
__le32 val;
+ int ret;
- usb_dbg(usbatm, "%s\n", __func__);
+ ret = cxacru_find_firmware(instance, "fw", &fw);
+ if (ret) {
+ usb_warn(usbatm_instance, "firmware (cxacru-fw.bin) unavailable (system misconfigured?)\n");
+ return ret;
+ }
+
+ if (instance->modem_type->boot_rom_patch) {
+ ret = cxacru_find_firmware(instance, "bp", &bp);
+ if (ret) {
+ usb_warn(usbatm_instance, "boot ROM patch (cxacru-bp.bin) unavailable (system misconfigured?)\n");
+ release_firmware(fw);
+ return ret;
+ }
+ }
/* FirmwarePllFClkValue */
val = cpu_to_le32(instance->modem_type->pll_f_clk);
ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, PLLFCLK_ADDR, (u8 *) &val, 4);
if (ret) {
usb_err(usbatm, "FirmwarePllFClkValue failed: %d\n", ret);
- return;
+ goto done;
}
/* FirmwarePllBClkValue */
@@ -1006,7 +1041,7 @@ static void cxacru_upload_firmware(struct cxacru_data *instance,
ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, PLLBCLK_ADDR, (u8 *) &val, 4);
if (ret) {
usb_err(usbatm, "FirmwarePllBClkValue failed: %d\n", ret);
- return;
+ goto done;
}
/* Enable SDRAM */
@@ -1014,7 +1049,7 @@ static void cxacru_upload_firmware(struct cxacru_data *instance,
ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, SDRAMEN_ADDR, (u8 *) &val, 4);
if (ret) {
usb_err(usbatm, "Enable SDRAM failed: %d\n", ret);
- return;
+ goto done;
}
/* Firmware */
@@ -1022,7 +1057,7 @@ static void cxacru_upload_firmware(struct cxacru_data *instance,
ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, FW_ADDR, fw->data, fw->size);
if (ret) {
usb_err(usbatm, "Firmware upload failed: %d\n", ret);
- return;
+ goto done;
}
/* Boot ROM patch */
@@ -1031,7 +1066,7 @@ static void cxacru_upload_firmware(struct cxacru_data *instance,
ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, BR_ADDR, bp->data, bp->size);
if (ret) {
usb_err(usbatm, "Boot ROM patching failed: %d\n", ret);
- return;
+ goto done;
}
}
@@ -1039,7 +1074,7 @@ static void cxacru_upload_firmware(struct cxacru_data *instance,
ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, SIG_ADDR, (u8 *) signature, 4);
if (ret) {
usb_err(usbatm, "Signature storing failed: %d\n", ret);
- return;
+ goto done;
}
usb_info(usbatm, "starting device\n");
@@ -1051,7 +1086,7 @@ static void cxacru_upload_firmware(struct cxacru_data *instance,
}
if (ret) {
usb_err(usbatm, "Passing control to firmware failed: %d\n", ret);
- return;
+ goto done;
}
/* Delay to allow firmware to start up. */
@@ -1065,53 +1100,10 @@ static void cxacru_upload_firmware(struct cxacru_data *instance,
ret = cxacru_cm(instance, CM_REQUEST_CARD_GET_STATUS, NULL, 0, NULL, 0);
if (ret < 0) {
usb_err(usbatm, "modem failed to initialize: %d\n", ret);
- return;
- }
-}
-
-static int cxacru_find_firmware(struct cxacru_data *instance,
- char *phase, const struct firmware **fw_p)
-{
- struct usbatm_data *usbatm = instance->usbatm;
- struct device *dev = &usbatm->usb_intf->dev;
- char buf[16];
-
- sprintf(buf, "cxacru-%s.bin", phase);
- usb_dbg(usbatm, "cxacru_find_firmware: looking for %s\n", buf);
-
- if (request_firmware(fw_p, buf, dev)) {
- usb_dbg(usbatm, "no stage %s firmware found\n", phase);
- return -ENOENT;
- }
-
- usb_info(usbatm, "found firmware %s\n", buf);
-
- return 0;
-}
-
-static int cxacru_heavy_init(struct usbatm_data *usbatm_instance,
- struct usb_interface *usb_intf)
-{
- const struct firmware *fw, *bp;
- struct cxacru_data *instance = usbatm_instance->driver_data;
- int ret = cxacru_find_firmware(instance, "fw", &fw);
-
- if (ret) {
- usb_warn(usbatm_instance, "firmware (cxacru-fw.bin) unavailable (system misconfigured?)\n");
- return ret;
+ goto done;
}
- if (instance->modem_type->boot_rom_patch) {
- ret = cxacru_find_firmware(instance, "bp", &bp);
- if (ret) {
- usb_warn(usbatm_instance, "boot ROM patch (cxacru-bp.bin) unavailable (system misconfigured?)\n");
- release_firmware(fw);
- return ret;
- }
- }
-
- cxacru_upload_firmware(instance, fw, bp);
-
+done:
if (instance->modem_type->boot_rom_patch)
release_firmware(bp);
release_firmware(fw);
]
|
| 110/2 |
2026/07/31 07:23 |
llm |
history-explorer |
0m
Model:
Tokens:
input: 16677
output: 31
thoughts: 172
Thoughts: **Analyzing the Scope of a Clang Warning Fix**
Okay, so this commit is just about cleaning up a Clang warning, nothing to do with URB (USB Request Block) cleanup itself. That's good to know. But, given the prompt's focus on similar root causes in related files, I should still explore potential connection to URB cleanup practices.
My first thought is to quickly scan for other URB-related commits within `drivers/usb/atm/`. I'll broaden the search to include commits touching error paths. I'll need to look for calls to functions like `usb_kill_urb`, `usb_free_urb`, or `usb_unlink_urb` to spot those. I'll expand the search to include `drivers/usb/core/` and `drivers/usb/` as well, as they're more general USB-related areas that might have relevant corrections.
Hold on a minute. The prompt's wording is key here: "similar root causes." Right, so I'm not just looking for any URB issues, but issues linked to missing locks, incorrect refcounting, or errors in error paths. That narrows the search.
Let's begin with checking for `usb_kill_urb` within `drivers/usb/atm/`. That's a reasonable first step to pinpoint possible fixes.
|
| 111/2 |
2026/07/31 07:23 |
tool |
grepper |
0m
Args: map[Expression:usb_kill_urb PathPrefix:drivers/usb/atm/]
Results: map[Output:drivers/usb/atm/cxacru.c=1230=static void cxacru_unbind(struct usbatm_data *usbatm_instance,
--
drivers/usb/atm/cxacru.c-1257-
drivers/usb/atm/cxacru.c:1258: usb_kill_urb(instance->snd_urb);
drivers/usb/atm/cxacru.c:1259: usb_kill_urb(instance->rcv_urb);
drivers/usb/atm/cxacru.c-1260- usb_free_urb(instance->snd_urb);
--
drivers/usb/atm/speedtch.c=687=static void speedtch_atm_stop(struct usbatm_data *usbatm, struct atm_dev *atm_dev)
--
drivers/usb/atm/speedtch.c-701- mb();
drivers/usb/atm/speedtch.c:702: usb_kill_urb(int_urb);
drivers/usb/atm/speedtch.c-703- timer_delete_sync(&instance->resubmit_timer);
--
drivers/usb/atm/speedtch.c-708- */
drivers/usb/atm/speedtch.c:709: usb_kill_urb(int_urb);
drivers/usb/atm/speedtch.c-710- timer_delete_sync(&instance->resubmit_timer);
--
drivers/usb/atm/ueagle-atm.c=2096=static int uea_boot(struct uea_softc *sc, struct usb_interface *intf)
--
drivers/usb/atm/ueagle-atm.c-2160-err2:
drivers/usb/atm/ueagle-atm.c:2161: usb_kill_urb(sc->urb_int);
drivers/usb/atm/ueagle-atm.c-2162-err1:
--
drivers/usb/atm/ueagle-atm.c=2173=static void uea_stop(struct uea_softc *sc)
--
drivers/usb/atm/ueagle-atm.c-2181-
drivers/usb/atm/ueagle-atm.c:2182: usb_kill_urb(sc->urb_int);
drivers/usb/atm/ueagle-atm.c-2183- kfree(sc->urb_int->transfer_buffer);
--
drivers/usb/atm/usbatm.c=1207=void usbatm_usb_disconnect(struct usb_interface *intf)
--
drivers/usb/atm/usbatm.c-1237- for (i = 0; i < num_rcv_urbs + num_snd_urbs; i++)
drivers/usb/atm/usbatm.c:1238: usb_kill_urb(instance->urbs[i]);
drivers/usb/atm/usbatm.c-1239-
]
|
| 112/2 |
2026/07/31 07:23 |
llm |
history-explorer |
0m
Model:
Tokens:
input: 17910
output: 41
thoughts: 19
Thoughts: Here's my attempt at summarizing the thought process, tailored for an expert audience:
**Diving into `ueagle-atm.c`**
Okay, time to get my hands dirty. I need to zero in on a specific area, and it looks like my gut feeling is pointing me towards `ueagle-atm.c`, specifically around line 2160. Given the nature of ATM-related code, there's a good chance this is where a critical function, potentially related to AAL signaling or cell processing, is located. I'm hoping I'll find the culprit there. I expect that line 2160 might mark the beginning of a key section, maybe a conditional statement, a function call, or a loop. I'll start by taking a close look at the surrounding code to understand the context and flow. My focus will be on the variables being used and their values in order to trace the sequence of events.
|
| 113/2 |
2026/07/31 07:24 |
tool |
read-file |
0m
Args: map[File:drivers/usb/atm/ueagle-atm.c FirstLine:2140 LineCount:40]
Results: map[Contents:2140:
2141: ret = usb_submit_urb(sc->urb_int, GFP_KERNEL);
2142: if (ret < 0) {
2143: uea_err(INS_TO_USBDEV(sc),
2144: "urb submission failed with error %d\n", ret);
2145: goto err1;
2146: }
2147:
2148: /* Create worker thread, but don't start it here. Start it after
2149: * all usbatm generic initialization is done.
2150: */
2151: sc->kthread = kthread_create(uea_kthread, sc, "ueagle-atm");
2152: if (IS_ERR(sc->kthread)) {
2153: uea_err(INS_TO_USBDEV(sc), "failed to create thread\n");
2154: ret = PTR_ERR(sc->kthread);
2155: goto err2;
2156: }
2157:
2158: return 0;
2159:
2160: err2:
2161: usb_kill_urb(sc->urb_int);
2162: err1:
2163: usb_free_urb(sc->urb_int);
2164: sc->urb_int = NULL;
2165: kfree(intr);
2166: err0:
2167: return ret;
2168: }
2169:
2170: /*
2171: * Stop the modem : kill kernel thread and free data
2172: */
2173: static void uea_stop(struct uea_softc *sc)
2174: {
2175: int ret;
2176:
2177: ret = kthread_stop(sc->kthread);
2178: uea_dbg(INS_TO_USBDEV(sc), "kthread finish with status %d\n", ret);
2179:
]
|
| 114/2 |
2026/07/31 07:24 |
llm |
history-explorer |
0m
Model:
Tokens:
input: 18749
output: 40
thoughts: 102
Thoughts: **Analyzing USB URB Error Handling**
Okay, so looking at `uea_boot()`, I see a clear pattern emerging. If `kthread_create()` fails, the code jumps to `err2` and immediately calls `usb_kill_urb(sc->urb_int)`. This confirms my initial hunch. We have a submitted URB, and if a later step goes south, the error handling involves killing that URB. It's a solid, predictable approach.
Now, I need to see how prevalent this is. I'm going to quickly check `cxacru.c` to see if this `usb_kill_urb` usage in error paths is common throughout the driver. My gut says it will be, but let's confirm.
|
| 115/2 |
2026/07/31 07:24 |
tool |
read-file |
0m
Args: map[File:drivers/usb/atm/cxacru.c FirstLine:630 LineCount:100]
Results: map[Contents: 630: init_completion(&instance->rcv_done);
631: ret = usb_submit_urb(instance->rcv_urb, GFP_KERNEL);
632: if (ret < 0) {
633: if (printk_ratelimit())
634: usb_err(instance->usbatm, "submit of read urb for cm %#x failed (%d)\n",
635: cm, ret);
636: goto fail;
637: }
638:
639: memset(wbuf, 0, wbuflen);
640: /* handle wsize == 0 */
641: wbuf[0] = cm;
642: for (offb = offd = 0; offd < wsize; offd += stride, offb += CMD_PACKET_SIZE) {
643: wbuf[offb] = cm;
644: memcpy(wbuf + offb + 4, wdata + offd, min_t(int, stride, wsize - offd));
645: }
646:
647: instance->snd_urb->transfer_buffer_length = wbuflen;
648: init_completion(&instance->snd_done);
649: ret = usb_submit_urb(instance->snd_urb, GFP_KERNEL);
650: if (ret < 0) {
651: if (printk_ratelimit())
652: usb_err(instance->usbatm, "submit of write urb for cm %#x failed (%d)\n",
653: cm, ret);
654: goto fail;
655: }
656:
657: ret = cxacru_start_wait_urb(instance->snd_urb, &instance->snd_done, NULL);
658: if (ret < 0) {
659: if (printk_ratelimit())
660: usb_err(instance->usbatm, "send of cm %#x failed (%d)\n", cm, ret);
661: goto fail;
662: }
663:
664: ret = cxacru_start_wait_urb(instance->rcv_urb, &instance->rcv_done, &actlen);
665: if (ret < 0) {
666: if (printk_ratelimit())
667: usb_err(instance->usbatm, "receive of cm %#x failed (%d)\n", cm, ret);
668: goto fail;
669: }
670: if (actlen % CMD_PACKET_SIZE || !actlen) {
671: if (printk_ratelimit())
672: usb_err(instance->usbatm, "invalid response length to cm %#x: %d\n",
673: cm, actlen);
674: ret = -EIO;
675: goto fail;
676: }
677:
678: /* check the return status and copy the data to the output buffer, if needed */
679: for (offb = offd = 0; offd < rsize && offb < actlen; offb += CMD_PACKET_SIZE) {
680: if (rbuf[offb] != cm) {
681: if (printk_ratelimit())
682: usb_err(instance->usbatm, "wrong cm %#x in response to cm %#x\n",
683: rbuf[offb], cm);
684: ret = -EIO;
685: goto fail;
686: }
687: if (rbuf[offb + 1] != CM_STATUS_SUCCESS) {
688: if (printk_ratelimit())
689: usb_err(instance->usbatm, "response to cm %#x failed: %#x\n",
690: cm, rbuf[offb + 1]);
691: ret = -EIO;
692: goto fail;
693: }
694: if (offd >= rsize)
695: break;
696: memcpy(rdata + offd, rbuf + offb + 4, min_t(int, stride, rsize - offd));
697: offd += stride;
698: }
699:
700: ret = offd;
701: usb_dbg(instance->usbatm, "cm %#x\n", cm);
702: fail:
703: mutex_unlock(&instance->cm_serialize);
704: err:
705: return ret;
706: }
707:
708: static int cxacru_cm_get_array(struct cxacru_data *instance, enum cxacru_cm_request cm,
709: u32 *data, int size)
710: {
711: int ret, len;
712: __le32 *buf;
713: int offb;
714: unsigned int offd;
715: const int stride = CMD_PACKET_SIZE / (4 * 2) - 1;
716: int buflen = ((size - 1) / stride + 1 + size * 2) * 4;
717:
718: buf = kmalloc(buflen, GFP_KERNEL);
719: if (!buf)
720: return -ENOMEM;
721:
722: ret = cxacru_cm(instance, cm, NULL, 0, (u8 *) buf, buflen);
723: if (ret < 0)
724: goto cleanup;
725:
726: /* len > 0 && len % 4 == 0 guaranteed by cxacru_cm() */
727: len = ret / 4;
728: for (offb = 0; offb < len; ) {
729: int l = le32_to_cpu(buf[offb++]);
]
|
| 116/2 |
2026/07/31 07:24 |
llm |
history-explorer |
0m
Model:
Tokens:
input: 20756
output: 44
thoughts: 168
Thoughts: **Analyzing a Potential USB URB Leak**
Okay, so I'm looking at this `cxacru_cm()` function and something's bugging me. Specifically, if `usb_submit_urb()` for the `snd_urb` fails, or if `cxacru_start_wait_urb()` fails, we immediately jump to `fail`. The problem is, `rcv_urb` has already been submitted at this point. If we just bail without doing anything, that `rcv_urb` is going to stay active and that's a problem.
The proposed solution seems straightforward: add `usb_kill_urb(instance->rcv_urb)` to the `fail` path. That makes sense, but hang on a minute... What about the `snd_urb`? Could that still be active when we hit `fail`? I need to double-check that. Let me quickly examine what `cxacru_start_wait_urb` does. Hmm, it looks like it already calls `usb_kill_urb` if there's a timeout or interrupt. So, we're probably covered there, but I need to make sure the code actually covers that scenario.
|
| 117/2 |
2026/07/31 07:24 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/usb/atm/cxacru.c Name:cxacru_start_wait_urb]
Results: map[SourceCode: 590: static int cxacru_start_wait_urb(struct urb *urb, struct completion *done,
591: int *actual_length)
592: {
593: struct cxacru_timer timer = {
594: .urb = urb,
595: };
596:
597: timer_setup_on_stack(&timer.timer, cxacru_timeout_kill, 0);
598: mod_timer(&timer.timer, jiffies + msecs_to_jiffies(CMD_TIMEOUT));
599: wait_for_completion(done);
600: timer_delete_sync(&timer.timer);
601: timer_destroy_on_stack(&timer.timer);
602:
603: if (actual_length)
604: *actual_length = urb->actual_length;
605: return urb->status; /* must read status after completion */
606: }
SourceFile:drivers/usb/atm/cxacru.c]
|
| 118/2 |
2026/07/31 07:24 |
llm |
history-explorer |
0m
Model:
Tokens:
input: 21527
output: 22
thoughts: 231
Thoughts: **My Analysis of the USB ATM Driver Issue**
Okay, so `cxacru_start_wait_urb` simply waits for the USB Request Block (URB) to finish. If the URB errors out during completion, it returns that error, naturally. It doesn't need to "kill" the URB, as the completion itself means it's no longer active. But, and this is important, if `cxacru_start_wait_urb` returns an error for the send URB (`snd_urb`), the receive URB (`rcv_urb`) is still running. We haven't waited on it yet. So, the suggested fix is clearly on the right track.
Now, I need to dig deeper. I want to see if there are any related commits that address similar problems in the code, things like missing locks, refcounting issues, or errors during execution. My initial thought was to check the `git log` for the `drivers/usb/atm/` directory within the last three years, but that only turned up a handful of commits, none of which were relevant to URB cleanup. Let me broaden the search to the entire history of `drivers/usb/atm/`. We might find similar fixes, even if they aren't recent. Sometimes these bugs repeat themselves, or the root cause manifests in different ways over time.
|
| 119/2 |
2026/07/31 07:24 |
tool |
git-log |
0m
Args: map[PathPrefix:drivers/usb/atm/]
Results: map[Output:9dfd800b374c usb: atm: ueagle-atm: reject descriptors that confuse probe and disconnect
e2674dfbed8a usb: atm: ueagle-atm: wait for pre-firmware load in .disconnect()
41d3e102edc2 atm: drv: Replace strcpy() + strlcat() with snprintf()
1414b2242c2e usb: atm: ueagle-atm: remove function entry/exit debug messages
05c5075c3115 usb: atm: ueagle-atm: use dev_dbg() for 'device found' message
bf4afc53b77a Convert 'alloc_obj' family to use the new default GFP_KERNEL argument
69050f8d6d07 treewide: Replace kmalloc with kmalloc_obj for non-scalar types
24c776355f40 kernel.h: drop hex.h and update all hex.h users
8d1b02e5d7e3 usb: atm: cxacru: Merge cxacru_upload_firmware() into cxacru_heavy_init()
41cb08555c41 treewide, timers: Rename from_timer() to timer_container_of()
]
|
| 120/2 |
2026/07/31 07:24 |
llm |
history-explorer |
0m
Model:
Tokens:
input: 22383
output: 35
thoughts: 23
Thoughts: Here's a summary of my immediate thought process:
**Thinking About `git log` Limits**
Okay, so I'm digging through some commit history, probably for debugging or trying to understand the evolution of a feature. And I'm using `git log`. Hang on a second... I know `git log` has a default limit. It's frustratingly easy to forget that it only shows the last 10 commits by default. I need to see more than that in this context. I can't rely on the default behavior here, I need a comprehensive view. Time to adjust the count, I need to make sure I get a sufficient number of entries.
|
| 121/2 |
2026/07/31 07:24 |
tool |
git-log |
0m
Args: map[Count:100 PathPrefix:drivers/usb/atm/ Since:3 years]
Results: map[Output:9dfd800b374c usb: atm: ueagle-atm: reject descriptors that confuse probe and disconnect
e2674dfbed8a usb: atm: ueagle-atm: wait for pre-firmware load in .disconnect()
41d3e102edc2 atm: drv: Replace strcpy() + strlcat() with snprintf()
1414b2242c2e usb: atm: ueagle-atm: remove function entry/exit debug messages
05c5075c3115 usb: atm: ueagle-atm: use dev_dbg() for 'device found' message
bf4afc53b77a Convert 'alloc_obj' family to use the new default GFP_KERNEL argument
69050f8d6d07 treewide: Replace kmalloc with kmalloc_obj for non-scalar types
24c776355f40 kernel.h: drop hex.h and update all hex.h users
8d1b02e5d7e3 usb: atm: cxacru: Merge cxacru_upload_firmware() into cxacru_heavy_init()
41cb08555c41 treewide, timers: Rename from_timer() to timer_container_of()
aad823aa3a7d treewide, timers: Rename destroy_timer_on_stack() as timer_destroy_on_stack()
8fa7292fee5c treewide: Switch/rename to timer_delete[_sync]()
c90aad369899 usb: atm: cxacru: fix a flaw in existing endpoint checks
5014f10c19ee usb: atm: Correct some typos
5f60d5f6bbc1 move asm/unaligned.h to linux/unaligned.h
2eabb655a968 usb: atm: cxacru: fix endpoint checking in cxacru_bind()
738ec5ab7acc usb: ueagle-atm: Use wait_event_freezable_timeout() in uea_wait()
36d8aef52d05 usb: atm: Remove snprintf() from sysfs call-backs and replace with sysfs_emit()
b7fa76e03b0d usb: atm: Use size_add() in call to struct_size()
]
|
| 122/2 |
2026/07/31 07:24 |
llm |
history-explorer |
0m
Model:
Tokens:
input: 23151
output: 25
thoughts: 29
Thoughts: Okay, here's my interpretation of those thoughts, crafted with the understanding that I'm speaking to a fellow expert:
**Investigating Potential Anomalies**
Alright, time to dive into this. Let's see what's going on with these commits, `c90aad369899` and `2eabb655a968`. The fact that we're specifically calling these out suggests they've triggered something, either directly or indirectly, in our monitoring. It could be performance regressions, unexpected behavior in testing, security implications, or even just some odd style choices that don't quite fit our established patterns. Gotta start digging, see what clues these IDs unlock. The deeper investigation begins!
|
| 123/2 |
2026/07/31 07:25 |
tool |
git-show |
0m
Args:
Results: map[Output:commit c90aad369899a607cfbc002bebeafd51e31900cd
Author: Nikita Zhandarovich <n.zhandarovich@fintech.ru>
Date: Thu Feb 13 15:22:57 2025 +0300
usb: atm: cxacru: fix a flaw in existing endpoint checks
Syzbot once again identified a flaw in usb endpoint checking, see [1].
This time the issue stems from a commit authored by me (2eabb655a968
("usb: atm: cxacru: fix endpoint checking in cxacru_bind()")).
While using usb_find_common_endpoints() may usually be enough to
discard devices with wrong endpoints, in this case one needs more
than just finding and identifying the sufficient number of endpoints
of correct types - one needs to check the endpoint's address as well.
Since cxacru_bind() fills URBs with CXACRU_EP_CMD address in mind,
switch the endpoint verification approach to usb_check_XXX_endpoints()
instead to fix incomplete ep testing.
[1] Syzbot report:
usb 5-1: BOGUS urb xfer, pipe 3 != type 1
WARNING: CPU: 0 PID: 1378 at drivers/usb/core/urb.c:504 usb_submit_urb+0xc4e/0x18c0 drivers/usb/core/urb.c:503
...
RIP: 0010:usb_submit_urb+0xc4e/0x18c0 drivers/usb/core/urb.c:503
...
Call Trace:
<TASK>
cxacru_cm+0x3c8/0xe50 drivers/usb/atm/cxacru.c:649
cxacru_card_status drivers/usb/atm/cxacru.c:760 [inline]
cxacru_bind+0xcf9/0x1150 drivers/usb/atm/cxacru.c:1223
usbatm_usb_probe+0x314/0x1d30 drivers/usb/atm/usbatm.c:1058
cxacru_usb_probe+0x184/0x220 drivers/usb/atm/cxacru.c:1377
usb_probe_interface+0x641/0xbb0 drivers/usb/core/driver.c:396
really_probe+0x2b9/0xad0 drivers/base/dd.c:658
__driver_probe_device+0x1a2/0x390 drivers/base/dd.c:800
driver_probe_device+0x50/0x430 drivers/base/dd.c:830
...
Reported-and-tested-by: syzbot+ccbbc229a024fa3e13b5@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=ccbbc229a024fa3e13b5
Fixes: 2eabb655a968 ("usb: atm: cxacru: fix endpoint checking in cxacru_bind()")
Cc: stable@kernel.org
Signed-off-by: Nikita Zhandarovich <n.zhandarovich@fintech.ru>
Link: https://lore.kernel.org/r/20250213122259.730772-1-n.zhandarovich@fintech.ru
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
index 0dd85d2635b9..47d06af33747 100644
--- a/drivers/usb/atm/cxacru.c
+++ b/drivers/usb/atm/cxacru.c
@@ -1131,7 +1131,10 @@ static int cxacru_bind(struct usbatm_data *usbatm_instance,
struct cxacru_data *instance;
struct usb_device *usb_dev = interface_to_usbdev(intf);
struct usb_host_endpoint *cmd_ep = usb_dev->ep_in[CXACRU_EP_CMD];
- struct usb_endpoint_descriptor *in, *out;
+ static const u8 ep_addrs[] = {
+ CXACRU_EP_CMD + USB_DIR_IN,
+ CXACRU_EP_CMD + USB_DIR_OUT,
+ 0};
int ret;
/* instance init */
@@ -1179,13 +1182,11 @@ static int cxacru_bind(struct usbatm_data *usbatm_instance,
}
if (usb_endpoint_xfer_int(&cmd_ep->desc))
- ret = usb_find_common_endpoints(intf->cur_altsetting,
- NULL, NULL, &in, &out);
+ ret = usb_check_int_endpoints(intf, ep_addrs);
else
- ret = usb_find_common_endpoints(intf->cur_altsetting,
- &in, &out, NULL, NULL);
+ ret = usb_check_bulk_endpoints(intf, ep_addrs);
- if (ret) {
+ if (!ret) {
usb_err(usbatm_instance, "cxacru_bind: interface has incorrect endpoints\n");
ret = -ENODEV;
goto fail;
]
|
| 124/2 |
2026/07/31 07:25 |
llm |
history-explorer |
0m
Model:
Tokens:
input: 24835
output: 25
thoughts: 28
Thoughts: Okay, here's my take on those thoughts, framed as an expert's inner monologue:
**Endpoint Verification Concerns**
Right, so this isn't about clearing out URBs, which is good. We're focused on endpoint validation here, which is the more critical issue. Now, let's get down to brass tacks. The critical piece of data is `2eabb655a968`. That's where the investigation starts. I need to dive into this identifier and see what we can learn. Let's see what that code points to. Is this a USB descriptor? Is this an I/O request packet? I need to analyze this identifier and figure out where this data takes us.
|
| 125/2 |
2026/07/31 07:25 |
tool |
git-show |
0m
Args:
Results: map[Output:commit 2eabb655a968b862bc0c31629a09f0fbf3c80d51
Author: Nikita Zhandarovich <n.zhandarovich@fintech.ru>
Date: Sun Jun 9 06:15:46 2024 -0700
usb: atm: cxacru: fix endpoint checking in cxacru_bind()
Syzbot is still reporting quite an old issue [1] that occurs due to
incomplete checking of present usb endpoints. As such, wrong
endpoints types may be used at urb sumbitting stage which in turn
triggers a warning in usb_submit_urb().
Fix the issue by verifying that required endpoint types are present
for both in and out endpoints, taking into account cmd endpoint type.
Unfortunately, this patch has not been tested on real hardware.
[1] Syzbot report:
usb 1-1: BOGUS urb xfer, pipe 1 != type 3
WARNING: CPU: 0 PID: 8667 at drivers/usb/core/urb.c:502 usb_submit_urb+0xed2/0x18a0 drivers/usb/core/urb.c:502
Modules linked in:
CPU: 0 PID: 8667 Comm: kworker/0:4 Not tainted 5.14.0-rc4-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Workqueue: usb_hub_wq hub_event
RIP: 0010:usb_submit_urb+0xed2/0x18a0 drivers/usb/core/urb.c:502
...
Call Trace:
cxacru_cm+0x3c0/0x8e0 drivers/usb/atm/cxacru.c:649
cxacru_card_status+0x22/0xd0 drivers/usb/atm/cxacru.c:760
cxacru_bind+0x7ac/0x11a0 drivers/usb/atm/cxacru.c:1209
usbatm_usb_probe+0x321/0x1ae0 drivers/usb/atm/usbatm.c:1055
cxacru_usb_probe+0xdf/0x1e0 drivers/usb/atm/cxacru.c:1363
usb_probe_interface+0x315/0x7f0 drivers/usb/core/driver.c:396
call_driver_probe drivers/base/dd.c:517 [inline]
really_probe+0x23c/0xcd0 drivers/base/dd.c:595
__driver_probe_device+0x338/0x4d0 drivers/base/dd.c:747
driver_probe_device+0x4c/0x1a0 drivers/base/dd.c:777
__device_attach_driver+0x20b/0x2f0 drivers/base/dd.c:894
bus_for_each_drv+0x15f/0x1e0 drivers/base/bus.c:427
__device_attach+0x228/0x4a0 drivers/base/dd.c:965
bus_probe_device+0x1e4/0x290 drivers/base/bus.c:487
device_add+0xc2f/0x2180 drivers/base/core.c:3354
usb_set_configuration+0x113a/0x1910 drivers/usb/core/message.c:2170
usb_generic_driver_probe+0xba/0x100 drivers/usb/core/generic.c:238
usb_probe_device+0xd9/0x2c0 drivers/usb/core/driver.c:293
Reported-and-tested-by: syzbot+00c18ee8497dd3be6ade@syzkaller.appspotmail.com
Fixes: 902ffc3c707c ("USB: cxacru: Use a bulk/int URB to access the command endpoint")
Cc: stable <stable@kernel.org>
Signed-off-by: Nikita Zhandarovich <n.zhandarovich@fintech.ru>
Link: https://lore.kernel.org/r/20240609131546.3932-1-n.zhandarovich@fintech.ru
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
index 4ce7cba2b48a..8f3b9a0a38e1 100644
--- a/drivers/usb/atm/cxacru.c
+++ b/drivers/usb/atm/cxacru.c
@@ -1131,6 +1131,7 @@ static int cxacru_bind(struct usbatm_data *usbatm_instance,
struct cxacru_data *instance;
struct usb_device *usb_dev = interface_to_usbdev(intf);
struct usb_host_endpoint *cmd_ep = usb_dev->ep_in[CXACRU_EP_CMD];
+ struct usb_endpoint_descriptor *in, *out;
int ret;
/* instance init */
@@ -1177,6 +1178,19 @@ static int cxacru_bind(struct usbatm_data *usbatm_instance,
goto fail;
}
+ if (usb_endpoint_xfer_int(&cmd_ep->desc))
+ ret = usb_find_common_endpoints(intf->cur_altsetting,
+ NULL, NULL, &in, &out);
+ else
+ ret = usb_find_common_endpoints(intf->cur_altsetting,
+ &in, &out, NULL, NULL);
+
+ if (ret) {
+ usb_err(usbatm_instance, "cxacru_bind: interface has incorrect endpoints\n");
+ ret = -ENODEV;
+ goto fail;
+ }
+
if ((cmd_ep->desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK)
== USB_ENDPOINT_XFER_INT) {
usb_fill_int_urb(instance->rcv_urb,
]
|
| 126/2 |
2026/07/31 07:25 |
llm |
history-explorer |
0m
Model:
Tokens:
input: 26729
output: 40
thoughts: 127
Thoughts: **Endpoint Investigation & Similar Fixes**
Okay, still deep in this endpoint investigation. My current thought process is this: I need to determine if there are any analogous fixes within the `drivers/usb/atm/` directory. The prompt is quite specific; it emphasizes looking for *similar* root causes, like missing locks, refcounting errors, or bugs in the error paths. So, I need to be diligent here. "If you find no relevant past fixes, clearly state that." I need to be sure.
Therefore, rather than getting bogged down in minor details right now, let's broaden the search a bit within `drivers/usb/atm/`. Let me look for commits that include mentions of `usb_kill_urb`, `usb_free_urb`, or `usb_unlink_urb` in their messages. This will give me a wider net to capture similar issues, even if the specifics are slightly different, and from here, I can narrow down my focus. I need a solid foundation for comparison.
|
| 127/2 |
2026/07/31 07:25 |
tool |
git-log |
0m
Args: map[CodeRegexp:usb_kill_urb Count:100 PathPrefix:drivers/usb/atm/]
Results: map[Output:b72458a80c75 [PATCH] USB: Eagle and ADI 930 usb adsl modem driver
1b0e61465234 [PATCH] USB ATM: driver for the Conexant AccessRunner chipset cxacru
48da7267ff16 [PATCH] USB ATM: port speedtch to new usbatm core
c59bba75fa50 [PATCH] USB ATM: new usbatm core
1da177e4c3f4 Linux-2.6.12-rc2
]
|
| 128/2 |
2026/07/31 07:25 |
llm |
history-explorer |
0m
Model:
Tokens:
input: 27254
output: 40
thoughts: 29
Thoughts: Okay, here's my interpretation of those thoughts, tailored for an expert audience, and delivered as a first-person summary:
**Digging into URB Unlinking**
Right, let me see... I'm tracing down this URB issue and I have a nagging feeling. I was focused on `usb_kill_urb`, assuming it was the go-to function. But hang on... wasn't that specific function, `usb_kill_urb`, only introduced in those *ancient* commits I was looking at? It seems like I'm focusing on the wrong function, now that I look back at it.
That's when it hit me... shouldn't I be primarily investigating `usb_unlink_urb` instead? That's the function that's generally used for *unlinking* an URB from its queue, rather than immediately terminating it, right? I need to go back and reassess those earlier traces and see if I was correctly identifying the functions used in those commits, or if I had gotten the functions mixed up!
|
| 129/2 |
2026/07/31 07:25 |
tool |
git-log |
0m
Args: map[CodeRegexp:usb_unlink_urb Count:100 PathPrefix:drivers/usb/atm/]
Results: map[Output:72a9f9a445d4 usb: usbatm: Convert timers to use timer_setup()
1b0e61465234 [PATCH] USB ATM: driver for the Conexant AccessRunner chipset cxacru
48da7267ff16 [PATCH] USB ATM: port speedtch to new usbatm core
1da177e4c3f4 Linux-2.6.12-rc2
]
|
| 130/2 |
2026/07/31 07:25 |
llm |
history-explorer |
0m
Model:
Tokens:
input: 27664
output: 40
thoughts: 10
Thoughts: Okay, here's my interpretation of that thought process, tailored for an expert audience, and written in the first person:
**Memory Management in USB URB Lifecycles**
Hmm, thinking about USB URBs... I'm mulling over a specific aspect of their lifecycle: **`usb_free_urb`**. It's a fundamental function, isn't it? The point at which resources tied to that URB are finally relinquished back to the system. From a performance perspective, I need to consider precisely what that function does under the hood. Does it perform the equivalent of a `kmem_cache_free()` call? Is it more complex? Does it involve de-allocating DMA mappings and other peripheral-specific resources, or does that happen earlier? Are we certain about the memory barriers required after deallocation? Are there any potential race conditions to worry about when an interrupt might occur during this process? I need to clarify the interaction between the URB itself, the associated buffers, and the device driver's context. I can't leave any room for memory leaks or dangling pointers. I should dig into the kernel source and make sure I'm fully aware of its nuances. It's a crucial point in the flow, I want to confirm that I have an intimate knowledge of that function.
|
| 131/2 |
2026/07/31 07:25 |
tool |
git-log |
0m
Args: map[CodeRegexp:usb_free_urb Count:100 PathPrefix:drivers/usb/atm/]
Results: map[Output:b72458a80c75 [PATCH] USB: Eagle and ADI 930 usb adsl modem driver
1b0e61465234 [PATCH] USB ATM: driver for the Conexant AccessRunner chipset cxacru
48da7267ff16 [PATCH] USB ATM: port speedtch to new usbatm core
c59bba75fa50 [PATCH] USB ATM: new usbatm core
1da177e4c3f4 Linux-2.6.12-rc2
]
|
| 132/2 |
2026/07/31 07:25 |
llm |
history-explorer |
0m
Model:
Tokens:
input: 28132
output: 33
thoughts: 51
Thoughts: **Investigating USB ATM Driver Cleanup**
Okay, so I'm looking into potential issues within the USB ATM driver, specifically concerning the cleanup of URBs. It appears there haven't been any recent commits directly addressing URB cleanup in the general `drivers/usb/atm/` directory. That's a bit of a starting point to consider.
Now, my next step is to drill down. I'm going to focus on a likely culprit, `drivers/usb/atm/cxacru.c`. This file often contains device-specific handling, including the error paths. It's a prime location to find potential URB cleanup flaws stemming from incorrect error handling. I'll need to carefully examine the commit history of that specific file. Hopefully there's something to uncover.
|
| 133/2 |
2026/07/31 07:25 |
tool |
git-log |
0m
Args: map[Count:100 PathPrefix:drivers/usb/atm/cxacru.c]
Results: map[Output:bf4afc53b77a Convert 'alloc_obj' family to use the new default GFP_KERNEL argument
69050f8d6d07 treewide: Replace kmalloc with kmalloc_obj for non-scalar types
8d1b02e5d7e3 usb: atm: cxacru: Merge cxacru_upload_firmware() into cxacru_heavy_init()
41cb08555c41 treewide, timers: Rename from_timer() to timer_container_of()
aad823aa3a7d treewide, timers: Rename destroy_timer_on_stack() as timer_destroy_on_stack()
8fa7292fee5c treewide: Switch/rename to timer_delete[_sync]()
c90aad369899 usb: atm: cxacru: fix a flaw in existing endpoint checks
5f60d5f6bbc1 move asm/unaligned.h to linux/unaligned.h
2eabb655a968 usb: atm: cxacru: fix endpoint checking in cxacru_bind()
b274e2a44e16 usb: atm: cxacru: Fix typo in comment
6d4e3866b765 drivers: usb: atm: use atm_info() instead of atm_printk(KERN_INFO ...
3291eb7329b1 drivers: usb: atm: reduce noise
cb06b385d536 usb: atm: don't use snprintf() for sysfs attrs
0d9b6d49fe39 usb: Use fallthrough pseudo-keyword
e605c30977bb USB: atm: cxacru: convert to use dev_groups
6453f53b752a USB: atm: fix up some remaining DEVICE_ATTR() usage
72a9f9a445d4 usb: usbatm: Convert timers to use timer_setup()
4a8635ae08e8 USB: atm: Remove redundant license text
5fd54ace4721 USB: add SPDX identifiers to all remaining files in drivers/usb/
3a851c031296 usb: atm: cxacru: mark expected switch fall-throughs
6a29d4b94431 drivers: usb: atm: cxacru: use setup_timer() helper.
9acd6b2a343d USB: atm: remove unneeded MODULE_VERSION() usage
78f74f75bd80 usb: atm: remove unnecessary code
04e75e495644 usb: atm: cxacru: don't print on ENOMEM
8ebbbf2e5dc0 usb: atm: cxacru: don't print error when allocating urb fails
46e3cafb01fe USB: cxacru: fix an bounds check warning
cd32fbad6e3d USB: atm: cxacru: fix blank line after declaration
803a536243b3 usb: delete non-required instances of include <linux/init.h>
2a0ebf80aa95 USB: cxacru: potential underflow in cxacru_cm_get_array()
77c9e125b3c8 USB: cxacru.c: remove dbg() usage
65db43054065 USB: convert drivers/usb/* to use module_usb_driver()
afe2c511fb2d workqueue: convert cancel_rearming_delayed_work[queue]() users to cancel_delayed_work_sync()
92e32eaee288 cxacru: ignore cx82310_eth devices
902ffc3c707c USB: cxacru: Use a bulk/int URB to access the command endpoint
83a3ac866d69 usb: conexant: fixed spacing and brace coding style issues
676f3d268682 usb/atm/cxacru.c: call atm_dev_signal_change() when signal changes.
30fa3d8ed0a6 USB: cxacru: increment driver version
817db5b34e70 USB: cxacru: remove cxacru-cf.bin loader
4ac37208e9b3 USB: cxacru: add write-only sysfs attribute for modem configuration
885582c48e5f USB: cxacru: firmware writes on OHCI are slow, log progress
c68bb0d73889 USB: cxacru: document how to interact with the flash memory
9fc950d32238 USB: cxacru: check device isn't being removed during sysfs calls
5d0a9c7932c4 USB: cxacru: check data length is not negative
1bfbd283cd30 USB: cxacru: return an empty value for modulation if there is no connection
10107bd04fc8 USB: cxacru: Fix negative dB output
eeafa64b7a41 USB: atm/cxacru, fix lock imbalance
7c510e4b730a net: convert more to %pM
230ffc75b7b8 USB: cxacru: Fix printk format flag in error message
33578bd706e4 USB: AccessRunner: avoid unnecessary memset
3b216d186c6d cxacru: treat firmware data as const
fd05e720099e drivers/usb annotations and fixes
cdc977922891 USB: remove unnecessary type casting of urb->context
4ac0718e8382 USB: cxacru: Use appropriate logging for errors
3b79cc26708b USB: unkill cxacru atm driver
c35f68a05d09 USB: atm: cxacru: clean up urb->status usage
87e71b473ee1 USB: cxacru: Cleanup sysfs attribute code
fd209e35b741 USB: cxacru: ignore error trying to start ADSL in atm_start
da1f82b55437 USB: cxacru: create sysfs attributes in atm_start instead of bind
6a02c996bce2 USB: cxacru: ADSL state management
fa70fe44aba9 USB: cxacru: export detailed device info through sysfs
c4028958b6ec WorkStruct: make allyesconfig
44960af1b6ab cxacru: add the ZTE ZXDSL 852
7d12e780e003 IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
ab3c81ff639f [PATCH] USBATM: semaphore to mutex conversion
80aae7a17afd [PATCH] USBATM: allow isochronous transfer
9a734efec36c [PATCH] USBATM: kzalloc conversion
0dfcd3e4444e [PATCH] USBATM: remove .owner
35644b0cce0a [PATCH] USBATM: add flags field
0ec3c7e85631 [PATCH] USBATM: trivial modifications
75318d2d7cab [PATCH] USB: remove .owner field from struct usb_driver
d3420ba4930d [PATCH] Additional device ID for Conexant AccessRunner USB driver
b375a0495fd6 [PATCH] USB: URB_ASYNC_UNLINK flag removed from the kernel
322a95bc8eba [PATCH] USB ATM: line speed measured in Kb not Kib
1b0e61465234 [PATCH] USB ATM: driver for the Conexant AccessRunner chipset cxacru
]
|
| 134/2 |
2026/07/31 07:25 |
llm |
history-explorer |
0m
Model:
Tokens:
input: 30276
output: 24
thoughts: 28
Thoughts: Here's a summary of my thought process, as if I were the one thinking it:
**Examining a Critical USB Fix**
Okay, time to dive into this commit hash: `eeafa64b7a41`. The description mentions a "fix [for] lock imbalance" specifically within the `atm/cxacru` driver related to USB. This immediately flags a potential area of concern. Lock imbalances, particularly in kernel-level drivers, can manifest in some nasty ways. They could lead to deadlocks, data corruption, performance degradation, or even subtle, intermittent issues that are a nightmare to debug. My expertise tells me that identifying the *exact* imbalance is crucial: is it a case of holding a lock for too long, acquiring locks in the wrong order, or releasing them prematurely? I need to understand the specifics of the `atm/cxacru` driver's locking strategy to fully assess the fix. Let's see what the commit changes look like. I'll need to scrutinize the lock acquisition and release points with extreme care. This will likely involve a deep dive into the code and potentially some reasoning with a debugger if things are subtle. This is a critical USB fix and it needs a thorough analysis.
|
| 135/2 |
2026/07/31 07:25 |
tool |
git-show |
0m
Args:
Results: map[Output:commit eeafa64b7a4134da24d48ed944e48541f8171152
Author: Jiri Slaby <jirislaby@kernel.org>
Date: Wed Mar 11 21:47:36 2009 +0100
USB: atm/cxacru, fix lock imbalance
We do not hold mutex in one place in cxacru_cm, but unlock it on fail path.
Fix this.
Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Cc: Simon Arlott <cxacru@fire.lp0.eu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
index 5ed4ae07bac1..6789089e2461 100644
--- a/drivers/usb/atm/cxacru.c
+++ b/drivers/usb/atm/cxacru.c
@@ -485,7 +485,7 @@ static int cxacru_cm(struct cxacru_data *instance, enum cxacru_cm_request cm,
usb_err(instance->usbatm, "requested transfer size too large (%d, %d)\n",
wbuflen, rbuflen);
ret = -ENOMEM;
- goto fail;
+ goto err;
}
mutex_lock(&instance->cm_serialize);
@@ -565,6 +565,7 @@ static int cxacru_cm(struct cxacru_data *instance, enum cxacru_cm_request cm,
dbg("cm %#x", cm);
fail:
mutex_unlock(&instance->cm_serialize);
+err:
return ret;
}
]
|
| 136/2 |
2026/07/31 07:25 |
llm |
history-explorer |
0m
Model:
Tokens:
input: 31087
output: 27
thoughts: 43
Thoughts: Okay, here's my interpretation of that.
**Analyzing a Simple Lock Imbalance Fix**
Alright, this looks like a straightforward fix for a lock imbalance, likely a classic concurrency issue. Let's dig in. I'm going to start by examining `c35f68a05d09` β that commit, specifically "USB: atm: cxacru: clean up urb->status usage". That's a reasonable starting point. The description strongly suggests this commit is related and should illuminate the lock usage and how the imbalance was corrected, so I'll review that change carefully.
|
| 137/2 |
2026/07/31 07:25 |
tool |
git-show |
0m
Args:
Results: map[Output:commit c35f68a05d0916e89ae2aab1a456f96fea9190cd
Author: Greg Kroah-Hartman <gregkh@suse.de>
Date: Wed Jul 18 10:58:02 2007 -0700
USB: atm: cxacru: clean up urb->status usage
This done in anticipation of removal of urb->status, which will make
that patch easier to review and apply in the future.
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
index 1bc884051e0f..02c52f8d5dbf 100644
--- a/drivers/usb/atm/cxacru.c
+++ b/drivers/usb/atm/cxacru.c
@@ -456,7 +456,7 @@ static int cxacru_start_wait_urb(struct urb *urb, struct completion *done,
int* actual_length)
{
struct timer_list timer;
- int status;
+ int status = urb->status;
init_timer(&timer);
timer.expires = jiffies + msecs_to_jiffies(CMD_TIMEOUT);
@@ -464,7 +464,6 @@ static int cxacru_start_wait_urb(struct urb *urb, struct completion *done,
timer.function = cxacru_timeout_kill;
add_timer(&timer);
wait_for_completion(done);
- status = urb->status;
del_timer_sync(&timer);
if (actual_length)
]
|
| 138/2 |
2026/07/31 07:25 |
llm |
history-explorer |
0m
Model:
Tokens:
input: 31759
output: 23
thoughts: 40
Thoughts: Okay, here's my take on those thoughts, framed as my own reasoning:
**Cleaning Up a Quick One**
Right, this is just a quick housekeeping item. Nothing earth-shattering, just tidying things up. Let's see what we've got in `8ebbbf2e5dc0`. Looks like it's in the USB subsystem, specifically the ATM driver for the cxacru chipset. The commit message indicates it's addressing a situation where we were being overly verbose by printing an error message when `urb` allocation fails. Okay, let's refresh my memory on the reasoning behind that decision and see what the fix entails. Probably dealing with a specific error handling branch.
|
| 139/2 |
2026/07/31 07:26 |
tool |
git-show |
0m
Args:
Results: map[Output:commit 8ebbbf2e5dc01599dcbf520463e9688e74133ad3
Author: Wolfram Sang <wsa-dev@sang-engineering.com>
Date: Thu Aug 11 23:14:32 2016 +0200
usb: atm: cxacru: don't print error when allocating urb fails
kmalloc will print enough information in case of failure.
Signed-off-by: Wolfram Sang <wsa-dev@sang-engineering.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
index 0a866e90b49c..18b281d73a39 100644
--- a/drivers/usb/atm/cxacru.c
+++ b/drivers/usb/atm/cxacru.c
@@ -1168,13 +1168,11 @@ static int cxacru_bind(struct usbatm_data *usbatm_instance,
}
instance->rcv_urb = usb_alloc_urb(0, GFP_KERNEL);
if (!instance->rcv_urb) {
- usb_dbg(usbatm_instance, "cxacru_bind: no memory for rcv_urb\n");
ret = -ENOMEM;
goto fail;
}
instance->snd_urb = usb_alloc_urb(0, GFP_KERNEL);
if (!instance->snd_urb) {
- usb_dbg(usbatm_instance, "cxacru_bind: no memory for snd_urb\n");
ret = -ENOMEM;
goto fail;
}
]
|
| 140/2 |
2026/07/31 07:26 |
llm |
history-explorer |
0m
Model:
Tokens:
input: 32452
output: 24
thoughts: 32
Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience:
**Analyzing the Relevant Context**
Hmm, "Not related" β that's a quick dismissal. I need to understand *why* that conclusion was reached. Was the initial context completely off-base, or did the subsequent analysis reveal a lack of connection? I'll have to keep that in mind when judging the overall validity.
Okay, let's dive into the detail, specifically examining commit `46e3cafb01fe`. Based on the context "USB: cxacru: fix an bounds check warning" I am already suspecting that this has to do with some kind of USB error. This sounds potentially relevant. I'm guessing the commit fixes a buffer overflow or some other boundary issue, probably within the `cxacru` driver. A bound check warning is a definite red flag. It could indicate a vulnerability, especially in a USB device driver, which often interacts with untrusted data from the connected device. This sounds like it may have the potential to be relevant. My attention is already at high alert to see if the issue is applicable.
|
| 141/2 |
2026/07/31 07:26 |
tool |
git-show |
0m
Args:
Results: map[Output:commit 46e3cafb01feb107a681e89fd9b4f1cd938a601f
Author: Dan Carpenter <error27@gmail.com>
Date: Sat Jan 30 17:34:55 2016 +0300
USB: cxacru: fix an bounds check warning
This is a privileged operation so it doesn't matter much. We use "tmp"
as an offset into an array. If it were invalid we could read out of
bounds and trigger an oops if the memory is not mapped. Plus it makes
static checkers complain.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
index 1173f9cbc137..0a866e90b49c 100644
--- a/drivers/usb/atm/cxacru.c
+++ b/drivers/usb/atm/cxacru.c
@@ -476,6 +476,8 @@ static ssize_t cxacru_sysfs_store_adsl_config(struct device *dev,
return -EINVAL;
if (index < 0 || index > 0x7f)
return -EINVAL;
+ if (tmp < 0 || tmp > len - pos)
+ return -EINVAL;
pos += tmp;
/* skip trailing newline */
]
|
| 142/2 |
2026/07/31 07:26 |
llm |
history-explorer |
0m
Model:
Tokens:
input: 33170
output: 25
thoughts: 41
Thoughts: Okay, here's my take on those thoughts, framed as an expert's internal monologue:
**Quick Scan & Divergence**
Hmm, "Not related"... that's a quick dismissal. I usually don't jump to conclusions that fast, but okay, I'll take that at face value for now. Gotta stay focused; I can always loop back later if something nags.
Right, let's pivot and look at `2a0ebf80aa95`. Oh, *that* one. USB: cxacru, specifically the "potential underflow in cxacru_cm_get_array()" call. Yup, I remember this. Always worth a double-check. Time to dig deeper and see if my expertise is needed.
|
| 143/2 |
2026/07/31 07:26 |
tool |
git-show |
0m
Args:
Results: map[Output:commit 2a0ebf80aa95cc758d4725f74a7016e992606a39
Author: Dan Carpenter <error27@gmail.com>
Date: Sun May 19 21:52:20 2013 +0300
USB: cxacru: potential underflow in cxacru_cm_get_array()
The value of "offd" comes off the instance->rcv_buf[] and we used it as
the offset into an array. The problem is that we check the upper bound
but not for negative values.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
index b7eb86ad6bf2..8a7eb77233b4 100644
--- a/drivers/usb/atm/cxacru.c
+++ b/drivers/usb/atm/cxacru.c
@@ -686,7 +686,8 @@ static int cxacru_cm_get_array(struct cxacru_data *instance, enum cxacru_cm_requ
{
int ret, len;
__le32 *buf;
- int offb, offd;
+ int offb;
+ unsigned int offd;
const int stride = CMD_PACKET_SIZE / (4 * 2) - 1;
int buflen = ((size - 1) / stride + 1 + size * 2) * 4;
]
|
| 144/2 |
2026/07/31 07:26 |
llm |
history-explorer |
0m
Model:
Tokens:
input: 33862
output: 26
thoughts: 40
Thoughts: Okay, let's see what we have here.
**Initial Assessment: Irrelevant & A Quick Divergence**
Hmm, the initial prompt seems unrelated to any ongoing task or problem I'm currently considering. It feels like a non-starter. But, given the prompt, let's check `fd209e35b741`. It seems to be related to USB and cxacru, likely some low-level network or modem driver behavior; specifically, it looks like it addresses an error related to starting ADSL, possibly in an ATM context. Let's briefly look into it.
|
| 145/2 |
2026/07/31 07:26 |
tool |
git-show |
0m
Args:
Results: map[Output:commit fd209e35b74110ee1f3371838b0782b5b02eaaba
Author: Simon Arlott <simon@octiron.net>
Date: Thu May 10 23:04:13 2007 -0700
USB: cxacru: ignore error trying to start ADSL in atm_start
The sysfs adsl_status attribute ignores (aside from returning -EIO to the
user) any error sending a START/STOP command to the device and there is at
least one firmware which never sends a response but appears to work
regardless. Therefore atm_start should also continue if an error is received
so that such firmware is usable.
The official Conexant driver doesn't expect a reply either but this is for
another device (E2 router) and a commonly used firmware does respond.
Also, there is no point in changing -ECONNRESET to -ETIMEDOUT since nothing
ever checks for either of these values.
Signed-off-by: Simon Arlott <simon@fire.lp0.eu>
Cc: Duncan Sands <duncan.sands@math.u-psud.fr>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
index 68cf582fd4fa..8bcf7fe1dd80 100644
--- a/drivers/usb/atm/cxacru.c
+++ b/drivers/usb/atm/cxacru.c
@@ -476,8 +476,6 @@ static int cxacru_start_wait_urb(struct urb *urb, struct completion *done,
add_timer(&timer);
wait_for_completion(done);
status = urb->status;
- if (status == -ECONNRESET)
- status = -ETIMEDOUT;
del_timer_sync(&timer);
if (actual_length)
@@ -671,11 +669,8 @@ static int cxacru_atm_start(struct usbatm_data *usbatm_instance,
/* start ADSL */
mutex_lock(&instance->adsl_state_serialize);
ret = cxacru_cm(instance, CM_REQUEST_CHIP_ADSL_LINE_START, NULL, 0, NULL, 0);
- if (ret < 0) {
+ if (ret < 0)
atm_err(usbatm_instance, "cxacru_atm_start: CHIP_ADSL_LINE_START returned %d\n", ret);
- mutex_unlock(&instance->adsl_state_serialize);
- return ret;
- }
/* Start status polling */
mutex_lock(&instance->poll_state_serialize);
]
|
| 146/2 |
2026/07/31 07:26 |
llm |
history-explorer |
0m
Model:
Tokens:
input: 34824
output: 31
thoughts: 335
Thoughts: **Analyzing a USB ATM Driver Bug**
Okay, so I'm looking at this commit, and it's ignoring the error return from `cxacru_cm` when requesting the ADSL line start. Hang on a second, the bug report says there's a problem in `cxacru_atm_start()` where the error is printed but then...ignored! And hey, this commit, `fd209e35b741`, that's *exactly* the one that introduced the error-ignoring behavior in `cxacru_atm_start()` which in turn leads to the subsequent call of `cxacru_poll_status()` even if `cxacru_cm()` failed earlier.
Ah, I see. `cxacru_cm()` failed, but it left the receive URB active. Then, `cxacru_poll_status()` calls `cxacru_cm_get_array()`, which calls `cxacru_cm()` *again* and that tries to resubmit the same URB, causing the warning! The root cause seems to be that `cxacru_cm()` doesn't clean up the URB when it errors, and the subsequent function calls don't handle the error properly.
So the fix is to make sure `cxacru_cm()` kills the URB on error, which makes perfect sense. The proposed patch addresses this by cleaning up the URB within the `cxacru_cm` function itself. Now, this likely resolves the immediate issue but this smells like a potential pattern.
Given that this is an ATM driver, I'm going to have to do a quick scan of the other functions within this driver. Let's see... I'll check `usbatm.c` to see if there's any other similar instances where URBs might be left in a problematic state. Hopefully, this fix can provide a good approach to address the existing bug and prevent similar ones in the future.
|
| 147/2 |
2026/07/31 07:26 |
tool |
grepper |
0m
Args: map[Expression:usb_kill_urb PathPrefix:drivers/usb/atm/]
Results: map[Output:drivers/usb/atm/cxacru.c=1230=static void cxacru_unbind(struct usbatm_data *usbatm_instance,
--
drivers/usb/atm/cxacru.c-1257-
drivers/usb/atm/cxacru.c:1258: usb_kill_urb(instance->snd_urb);
drivers/usb/atm/cxacru.c:1259: usb_kill_urb(instance->rcv_urb);
drivers/usb/atm/cxacru.c-1260- usb_free_urb(instance->snd_urb);
--
drivers/usb/atm/speedtch.c=687=static void speedtch_atm_stop(struct usbatm_data *usbatm, struct atm_dev *atm_dev)
--
drivers/usb/atm/speedtch.c-701- mb();
drivers/usb/atm/speedtch.c:702: usb_kill_urb(int_urb);
drivers/usb/atm/speedtch.c-703- timer_delete_sync(&instance->resubmit_timer);
--
drivers/usb/atm/speedtch.c-708- */
drivers/usb/atm/speedtch.c:709: usb_kill_urb(int_urb);
drivers/usb/atm/speedtch.c-710- timer_delete_sync(&instance->resubmit_timer);
--
drivers/usb/atm/ueagle-atm.c=2096=static int uea_boot(struct uea_softc *sc, struct usb_interface *intf)
--
drivers/usb/atm/ueagle-atm.c-2160-err2:
drivers/usb/atm/ueagle-atm.c:2161: usb_kill_urb(sc->urb_int);
drivers/usb/atm/ueagle-atm.c-2162-err1:
--
drivers/usb/atm/ueagle-atm.c=2173=static void uea_stop(struct uea_softc *sc)
--
drivers/usb/atm/ueagle-atm.c-2181-
drivers/usb/atm/ueagle-atm.c:2182: usb_kill_urb(sc->urb_int);
drivers/usb/atm/ueagle-atm.c-2183- kfree(sc->urb_int->transfer_buffer);
--
drivers/usb/atm/usbatm.c=1207=void usbatm_usb_disconnect(struct usb_interface *intf)
--
drivers/usb/atm/usbatm.c-1237- for (i = 0; i < num_rcv_urbs + num_snd_urbs; i++)
drivers/usb/atm/usbatm.c:1238: usb_kill_urb(instance->urbs[i]);
drivers/usb/atm/usbatm.c-1239-
]
|
| 148/2 |
2026/07/31 07:26 |
llm |
history-explorer |
0m
Model:
Tokens:
input: 36355
output: 44
thoughts: 135
Thoughts: **Analyzing USB Error Path Fixes**
Okay, so the task at hand is to dig into the history of fixes related to similar bugs within the USB subsystem, specifically focusing on error paths. The prompt wants me to identify recurring patterns, idioms, or locking rules that have been applied to resolve these kinds of issues in the past. Essentially, it's asking me to become a bug-fixing archeologist, reconstructing best practices from the fossil record of commits.
The most efficient starting point, given the context, seems to be a focused search. Rather than casting a wide net initially, I'll begin by targeting a known function, `usb_kill_urb`, within the `drivers/usb/` directory. This function is likely a key point of failure. I'll need to expand my search terms to include error path investigations. This approach should help uncover instances where similar errors in USB handling have been addressed.
My ultimate goal, of course, isn't just to find *fixes*, but to understand *why* those fixes worked. I want to extract the underlying principles. Was it a missing lock, incorrect reference counting, a flaw in the error handling logic, or some other common pitfall? I'm looking for the *root cause* and how it was addressed in previous USB-related fixes. If nothing turns up I'll have to make that explicit in the final response.
|
| 149/2 |
2026/07/31 07:26 |
tool |
git-log |
0m
Args: map[CodeRegexp:usb_kill_urb Count:50 PathPrefix:drivers/usb/ Since:3 years]
Results: map[Output:42a97c0480f9 USB: serial: keyspan_pda: fix data loss on receive throttling
c602254ba4c1 USB: iowarrior: fix use-after-free on disconnect race
1be3b77de4eb usb: image: mdc800: kill download URB on timeout
121a0f839dbb usb: misc: Add Intel USBIO bridge driver
47c83f95f3e2 usb: core: Remove unused usb_unlink_anchored_urbs
c15a688e4998 USB: serial: mos7840: fix crash on resume
acd6199f195d usb: Add support for Intel LJCA device
]
|
| 150/2 |
2026/07/31 07:26 |
llm |
history-explorer |
0m
Model:
Tokens:
input: 37013
output: 24
thoughts: 33
Thoughts: Okay, here's my interpretation of that thought process, assuming I'm deep in the weeds on a USB driver issue:
**Deep Dive: Timeout Kill**
Alright, time to dive into this one: `1be3b77de4eb`. "usb: image: mdc800: kill download URB on timeout." Right, so we're talking about a USB image transfer, likely related to the MDC800 device, and specifically what happens when a download request times out. That's a good starting point. I need to understand what's triggering this timeout and where the code attempts to address the problem, specifically the "kill download URB" part.
I'm assuming this patch addresses a scenario where the USB transfer isn't completing within the expected timeframe. Is it the host side or the device side that's causing the delay? Does the patch provide a mechanism to clean up, prevent further errors, or does it attempt to retry? What's the impact of this "kill" operation? Does it correctly free resources, or could it leave things in a corrupted state? My first line of investigation will be to examine the surrounding code to determine how this patch fits into the overall process.
|
| 151/2 |
2026/07/31 07:26 |
tool |
git-show |
0m
Args:
Results: map[Output:commit 1be3b77de4eb89af8ae2fd6610546be778e25589
Author: Ziyi Guo <n7l8m4@u.northwestern.edu>
Date: Mon Feb 9 15:19:37 2026 +0000
usb: image: mdc800: kill download URB on timeout
mdc800_device_read() submits download_urb and waits for completion.
If the timeout fires and the device has not responded, the function
returns without killing the URB, leaving it active.
A subsequent read() resubmits the same URB while it is still
in-flight, triggering the WARN in usb_submit_urb():
"URB submitted while active"
Check the return value of wait_event_timeout() and kill the URB if
it indicates timeout, ensuring the URB is complete before its status
is inspected or the URB is resubmitted.
Similar to
- commit 372c93131998 ("USB: yurex: fix control-URB timeout handling")
- commit b98d5000c505 ("media: rc: iguanair: handle timeouts")
Signed-off-by: Ziyi Guo <n7l8m4@u.northwestern.edu>
Cc: stable <stable@kernel.org>
Link: https://patch.msgid.link/20260209151937.2247202-1-n7l8m4@u.northwestern.edu
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
diff --git a/drivers/usb/image/mdc800.c b/drivers/usb/image/mdc800.c
index e76a502fa9da..ca287b770e8c 100644
--- a/drivers/usb/image/mdc800.c
+++ b/drivers/usb/image/mdc800.c
@@ -730,9 +730,11 @@ static ssize_t mdc800_device_read (struct file *file, char __user *buf, size_t l
mutex_unlock(&mdc800->io_lock);
return len-left;
}
- wait_event_timeout(mdc800->download_wait,
+ retval = wait_event_timeout(mdc800->download_wait,
mdc800->downloaded,
msecs_to_jiffies(TO_DOWNLOAD_GET_READY));
+ if (!retval)
+ usb_kill_urb(mdc800->download_urb);
mdc800->downloaded = 0;
if (mdc800->download_urb->status != 0)
{
]
|
| 152/2 |
2026/07/31 07:26 |
llm |
history-explorer |
0m
Model:
Tokens:
input: 38082
output: 27
thoughts: 142
Thoughts: **USB URB Timeout Handling - A Familiar Pattern**
Alright, this is crystal clear. I'm seeing the same underlying issue pop up again: "kill download URB on timeout." Basically, if a USB Request Block (URB) times out while waiting, the system leaves the URB active, which is, of course, a problem. The correct solution, as always, is to call `usb_kill_urb()` in the error handling path.
The commit message is smart; it's pointing to previous instances of this same class of issue. Looks like we have two very similar commits to look at for some comparison: `372c93131998` ("USB: yurex: fix control-URB timeout handling") and `b98d5000c505` ("media: rc: iguanair: handle timeouts"). Let's focus our attention on `372c93131998` first and see what lessons we can learn from that. This feels like it will likely be a good starting point for our investigation.
|
| 153/2 |
2026/07/31 07:27 |
tool |
git-show |
0m
Args:
Results: map[Output:commit 372c93131998c0622304bed118322d2a04489e63
Author: Johan Hovold <johan@kernel.org>
Date: Mon Dec 14 11:30:53 2020 +0100
USB: yurex: fix control-URB timeout handling
Make sure to always cancel the control URB in write() so that it can be
reused after a timeout or spurious CMD_ACK.
Currently any further write requests after a timeout would fail after
triggering a WARN() in usb_submit_urb() when attempting to submit the
already active URB.
Reported-by: syzbot+e87ebe0f7913f71f2ea5@syzkaller.appspotmail.com
Fixes: 6bc235a2e24a ("USB: add driver for Meywa-Denki & Kayac YUREX")
Cc: stable <stable@vger.kernel.org> # 2.6.37
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
diff --git a/drivers/usb/misc/yurex.c b/drivers/usb/misc/yurex.c
index 73ebfa6e9715..c640f98d20c5 100644
--- a/drivers/usb/misc/yurex.c
+++ b/drivers/usb/misc/yurex.c
@@ -496,6 +496,9 @@ static ssize_t yurex_write(struct file *file, const char __user *user_buffer,
timeout = schedule_timeout(YUREX_WRITE_TIMEOUT);
finish_wait(&dev->waitq, &wait);
+ /* make sure URB is idle after timeout or (spurious) CMD_ACK */
+ usb_kill_urb(dev->cntl_urb);
+
mutex_unlock(&dev->io_mutex);
if (retval < 0) {
]
|
| 154/2 |
2026/07/31 07:27 |
llm |
history-explorer |
0m
Model:
Tokens:
input: 39046
output: 27
thoughts: 61
Thoughts: Okay, let's break this down.
**Analyzing a USB Write Request Failure Pattern**
Alright, I'm seeing a recurring issue here. It looks like we've got a consistent failure pattern with USB write requests after a timeout occurs. Specifically, any subsequent write attempts *after* that initial timeout are failing. This triggers a `WARN()` message within `usb_submit_urb()`, which suggests that we're trying to submit a Universal Serial Bus Request Block (URB) that's already in an active state. That's not good. We are probably dealing with a double submission.
My next step is to dig into the commit `b98d5000c505`. That's where I need to start to understand the history of this particular piece of code and to look for any clues to the origin of this problem. This could be where the bug was introduced, or where some related refactoring occurred that exposed a pre-existing issue. I'll need to review the changes carefully for any potential race conditions, incorrect state handling, or assumptions that could be leading to this. Let's get to work.
|
| 155/2 |
2026/07/31 07:27 |
tool |
git-show |
0m
Args:
Results: map[Output:commit b98d5000c50544f14bacb248c34e5219fbe81287
Author: Oliver Neukum <oneukum@suse.com>
Date: Tue Nov 26 14:17:22 2024 +0100
media: rc: iguanair: handle timeouts
In case of a timeout the IO must be cancelled or
the next IO using the URB will fail and/or overwrite
an operational URB.
The automatic bisection fails because it arrives
at a commit that correctly lets the test case run
without an error.
Signed-off-by: Oliver Neukum <oneukum@suse.com>
Fixes: e99a7cfe93fd ("[media] iguanair: reuse existing urb callback for command responses")
Reported-by: syzbot+ffba8e636870dac0e0c0@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/all/66f5cc9a.050a0220.46d20.0004.GAE@google.com/
Tested-by: syzbot+ffba8e636870dac0e0c0@syzkaller.appspotmail.com
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
diff --git a/drivers/media/rc/iguanair.c b/drivers/media/rc/iguanair.c
index 276bf3c8a8cb..8af94246e591 100644
--- a/drivers/media/rc/iguanair.c
+++ b/drivers/media/rc/iguanair.c
@@ -194,8 +194,10 @@ static int iguanair_send(struct iguanair *ir, unsigned size)
if (rc)
return rc;
- if (wait_for_completion_timeout(&ir->completion, TIMEOUT) == 0)
+ if (wait_for_completion_timeout(&ir->completion, TIMEOUT) == 0) {
+ usb_kill_urb(ir->urb_out);
return -ETIMEDOUT;
+ }
return rc;
}
]
|
| 156/2 |
2026/07/31 07:27 |
llm |
history-explorer |
1m
Model:
Tokens:
input: 39992
output: 44
thoughts: 686
Thoughts: **My Analysis of the USB URB Error Handling Pattern**
Okay, here's what I've distilled from this. I'm seeing a clear and recurring pattern in USB driver code. It's a classic: when a driver submits an URB, waits for it, and then hits an error *during* that wait or immediately *after* (like a timeout, a secondary URB failure, or an issue when waiting for the first URB), the driver **must** immediately and explicitly clean up by using `usb_kill_urb()` on *all* submitted URBs before bailing out and returning that error. Otherwise, those URBs are left hanging. And if the driver then tries to reuse that URB laterβmaybe in a subsequent call, or even just in a polling loopβit's going to trigger the dreaded "URB submitted while active" warning in `usb_submit_urb()`. It's like leaving a thread un-joined; it causes contention later.
Specifically, in this `cxacru_cm()` case, it submits both `rcv_urb` and `snd_urb`. The problem is that if `snd_urb` fails to submit or complete, the function correctly returns an error. But it doesn't take the time to clean up `rcv_urb`, leaving it active and waiting for who knows what? The fix is glaringly obvious: just add a `usb_kill_urb(instance->rcv_urb)` call in that error path. Simple as that.
I've done some digging, and this isn't a one-off. I can trace it back to a commit that introduced a subtle bug by ignoring a return code and thus leaving the URB in an active state.
I expanded the search to the entire `drivers/usb/` subsystem and found several related commits: I've seen fixes like this before: ("usb: image: mdc800: kill download URB on timeout", "USB: yurex: fix control-URB timeout handling", "media: rc: iguanair: handle timeouts"). All of these exhibit the same fundamental flaw and the same crucial correction. The pattern is consistent.
The real beauty here is that `usb_kill_urb()` is robust. It's safe to call unconditionally, even if the URB *isn't* actually active (maybe it already completed, or was never submitted in the first place). This means we can just drop it into the error cleanup code without worrying about edge cases or extra checks. This makes it a very useful defensive programming tool.
Just to be absolutely sure, I'll double-check for any more similar commits in `drivers/usb/`. It's always good to be thorough.
|
| 157/2 |
2026/07/31 07:28 |
tool |
git-log |
0m
Args: map[CodeRegexp:usb_kill_urb Count:10 PathPrefix:drivers/usb/ Since:3 years]
Results: map[Output:42a97c0480f9 USB: serial: keyspan_pda: fix data loss on receive throttling
c602254ba4c1 USB: iowarrior: fix use-after-free on disconnect race
1be3b77de4eb usb: image: mdc800: kill download URB on timeout
121a0f839dbb usb: misc: Add Intel USBIO bridge driver
47c83f95f3e2 usb: core: Remove unused usb_unlink_anchored_urbs
c15a688e4998 USB: serial: mos7840: fix crash on resume
acd6199f195d usb: Add support for Intel LJCA device
]
|
| 158/2 |
2026/07/31 07:28 |
llm |
history-explorer |
0m
Model:
Tokens:
input: 41493
output: 26
thoughts: 164
Thoughts: **Analyzing USB Driver Code**
Okay, let's see... looking back over the last three years in the `drivers/usb/` directory, the commit hash `1be3b77de4eb` is the only one that perfectly fits the search criteria. Interesting. The other two, `372c93131998` and `b98d5000c505`, were only found because they were mentioned in the commit message of `1be3b77de4eb`, so they're not directly matching the pattern. Also, it's worth noting that `b98d5000c505` lives in `drivers/media/rc/iguanair.c`, which is a different USB driver. Hmm, could be relevant.
Now, let's shift gears and check out `c602254ba4c1` β that commit looks like it addresses a use-after-free issue on disconnect within the USB iowarrior driver. Good starting point.
|
| 159/2 |
2026/07/31 07:28 |
tool |
git-show |
0m
Args:
Results: map[Output:commit c602254ba4c10f60a73cd99d147874f86a3f485c
Author: Johan Hovold <johan@kernel.org>
Date: Mon Jun 22 17:26:09 2026 +0200
USB: iowarrior: fix use-after-free on disconnect race
mutex_unlock() may access the mutex structure after releasing the lock
and therefore cannot be used to manage lifetime of objects directly
(unlike spinlocks and refcounts). [1][2]
Use a kref to release the driver data to avoid use-after-free in
mutex_unlock() when release() races with disconnect().
[1] a51749ab34d9 ("locking/mutex: Document that mutex_unlock() is non-atomic")
[2] 2b9d9e0a9ba0 ("locking/mutex: Clarify that mutex_unlock(), and most
other sleeping locks, can still use the lock object
after it's unlocked")
Fixes: 946b960d13c1 ("USB: add driver for iowarrior devices.")
Cc: stable <stable@kernel.org>
Reported-by: Yue Sun <samsun1006219@gmail.com>
Link: https://lore.kernel.org/r/20260618080204.38322-1-samsun1006219@gmail.com
Signed-off-by: Johan Hovold <johan@kernel.org>
Link: https://patch.msgid.link/20260622152612.116422-2-johan@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c
index 88c6d1d1da11..de2b236ef903 100644
--- a/drivers/usb/misc/iowarrior.c
+++ b/drivers/usb/misc/iowarrior.c
@@ -72,6 +72,7 @@ static struct usb_driver iowarrior_driver;
/* Structure to hold all of our device specific stuff */
struct iowarrior {
+ struct kref kref;
struct mutex mutex; /* locks this structure */
struct usb_device *udev; /* save off the usb device pointer */
struct usb_interface *interface; /* the interface for this device */
@@ -240,8 +241,10 @@ static void iowarrior_write_callback(struct urb *urb)
/*
* iowarrior_delete
*/
-static inline void iowarrior_delete(struct iowarrior *dev)
+static inline void iowarrior_delete(struct kref *kref)
{
+ struct iowarrior *dev = container_of(kref, struct iowarrior, kref);
+
kfree(dev->int_in_buffer);
usb_free_urb(dev->int_in_urb);
kfree(dev->read_queue);
@@ -637,6 +640,9 @@ static int iowarrior_open(struct inode *inode, struct file *file)
}
/* increment our usage count for the driver */
++dev->opened;
+
+ kref_get(&dev->kref);
+
/* save our object in the file's private structure */
file->private_data = dev;
retval = 0;
@@ -652,7 +658,6 @@ static int iowarrior_open(struct inode *inode, struct file *file)
static int iowarrior_release(struct inode *inode, struct file *file)
{
struct iowarrior *dev;
- int retval = 0;
dev = file->private_data;
if (!dev)
@@ -660,29 +665,18 @@ static int iowarrior_release(struct inode *inode, struct file *file)
/* lock our device */
mutex_lock(&dev->mutex);
+ dev->opened = 0; /* we're closing now */
- if (dev->opened <= 0) {
- retval = -ENODEV; /* close called more than once */
- mutex_unlock(&dev->mutex);
- } else {
- dev->opened = 0; /* we're closing now */
- retval = 0;
- if (dev->present) {
- /*
- The device is still connected so we only shutdown
- pending read-/write-ops.
- */
- usb_kill_urb(dev->int_in_urb);
- wake_up_interruptible(&dev->read_wait);
- wake_up_interruptible(&dev->write_wait);
- mutex_unlock(&dev->mutex);
- } else {
- /* The device was unplugged, cleanup resources */
- mutex_unlock(&dev->mutex);
- iowarrior_delete(dev);
- }
+ if (dev->present) {
+ usb_kill_urb(dev->int_in_urb);
+ wake_up_interruptible(&dev->read_wait);
+ wake_up_interruptible(&dev->write_wait);
}
- return retval;
+ mutex_unlock(&dev->mutex);
+
+ kref_put(&dev->kref, iowarrior_delete);
+
+ return 0;
}
static __poll_t iowarrior_poll(struct file *file, poll_table * wait)
@@ -767,6 +761,7 @@ static int iowarrior_probe(struct usb_interface *interface,
if (!dev)
return retval;
+ kref_init(&dev->kref);
mutex_init(&dev->mutex);
atomic_set(&dev->intr_idx, 0);
@@ -885,7 +880,8 @@ static int iowarrior_probe(struct usb_interface *interface,
return retval;
error:
- iowarrior_delete(dev);
+ kref_put(&dev->kref, iowarrior_delete);
+
return retval;
}
@@ -909,19 +905,14 @@ static void iowarrior_disconnect(struct usb_interface *interface)
usb_kill_anchored_urbs(&dev->submitted);
if (dev->opened) {
- /* There is a process that holds a filedescriptor to the device ,
- so we only shutdown read-/write-ops going on.
- Deleting the device is postponed until close() was called.
- */
usb_kill_urb(dev->int_in_urb);
wake_up_interruptible(&dev->read_wait);
wake_up_interruptible(&dev->write_wait);
- mutex_unlock(&dev->mutex);
- } else {
- /* no process is using the device, cleanup now */
- mutex_unlock(&dev->mutex);
- iowarrior_delete(dev);
}
+
+ mutex_unlock(&dev->mutex);
+
+ kref_put(&dev->kref, iowarrior_delete);
}
/* usb specific object needed to register this driver with the usb subsystem */
]
|
| 160/2 |
2026/07/31 07:28 |
llm |
history-explorer |
0m
Model:
Tokens:
input: 43846
output: 27
thoughts: 50
Thoughts: Here's my analysis of the provided context, framed as my own thought process:
**Diving into Kernel Concurrency and Resource Management**
Okay, so we're looking at a situation involving `kref` and `mutex_unlock`. My immediate thought is, this likely involves a resource management scenario, probably within the context of a kernel module, specifically around how the driver uses reference counting and mutexes to protect shared data structures. This suggests we're dealing with concurrent access and potential race conditions. The combination of `kref` and `mutex_unlock` often indicates a critical section managed with a lock, and the need to release the mutex when a resource is freed using reference counting.
Let's see what `42a97c0480f9` tells us. USB, serial, keyspan_pda... aha! This looks like a fix related to a specific USB-to-serial driver, Keyspan PDA. The commit message indicates that data loss happens with receive throttling, which means it likely has some design flaw in handling input buffer and concurrent access to the receive buffer.
I'll probably need to look into this commit to understand how the mutex and reference counting are used in context with the receive buffer and any related data structures. This particular commit likely addresses a race condition, where data is being written and read from the input buffer at the same time and the buffer is freed too early, causing data loss.
|
| 161/2 |
2026/07/31 07:28 |
tool |
git-show |
0m
Args:
Results: map[Output:commit 42a97c0480f96a2977e6d51ce512adc780f1ef5d
Author: Johan Hovold <johan@kernel.org>
Date: Wed Jul 8 16:31:35 2026 +0200
USB: serial: keyspan_pda: fix data loss on receive throttling
Killing the interrupt-in urb when the line disciple requests throttling
may lead to data loss if an ongoing transfer is cancelled.
Instead set a flag to prevent the completion handler from resubmitting
the urb until the port is unthrottled.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Cc: stable@vger.kernel.org
Signed-off-by: Johan Hovold <johan@kernel.org>
diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c
index f05bcce60600..dd4cfd17f7ad 100644
--- a/drivers/usb/serial/keyspan_pda.c
+++ b/drivers/usb/serial/keyspan_pda.c
@@ -33,6 +33,8 @@ struct keyspan_pda_private {
struct work_struct unthrottle_work;
struct usb_serial *serial;
struct usb_serial_port *port;
+ bool throttled;
+ bool throttle_req;
};
static int keyspan_pda_write_start(struct usb_serial_port *port);
@@ -148,6 +150,7 @@ static void keyspan_pda_rx_interrupt(struct urb *urb)
int retval;
int status = urb->status;
struct keyspan_pda_private *priv;
+ bool throttled = false;
unsigned long flags;
priv = usb_get_serial_port_data(port);
@@ -209,16 +212,24 @@ static void keyspan_pda_rx_interrupt(struct urb *urb)
}
exit:
- retval = usb_submit_urb(urb, GFP_ATOMIC);
- if (retval)
- dev_err(&port->dev,
- "%s - usb_submit_urb failed with result %d\n",
- __func__, retval);
+ spin_lock_irqsave(&port->lock, flags);
+ if (priv->throttle_req) {
+ priv->throttled = true;
+ throttled = true;
+ }
+ spin_unlock_irqrestore(&port->lock, flags);
+
+ if (!throttled) {
+ retval = usb_submit_urb(urb, GFP_ATOMIC);
+ if (retval)
+ dev_err(&port->dev, "failed to resubmit in urb: %d\n", retval);
+ }
}
static void keyspan_pda_rx_throttle(struct tty_struct *tty)
{
struct usb_serial_port *port = tty->driver_data;
+ struct keyspan_pda_private *priv = usb_get_serial_port_data(port);
/*
* Stop receiving characters. We just turn off the URB request, and
@@ -228,16 +239,29 @@ static void keyspan_pda_rx_throttle(struct tty_struct *tty)
* send an XOFF, although it might make sense to foist that off upon
* the device too.
*/
- usb_kill_urb(port->interrupt_in_urb);
+ spin_lock_irq(&port->lock);
+ priv->throttle_req = true;
+ spin_unlock_irq(&port->lock);
}
static void keyspan_pda_rx_unthrottle(struct tty_struct *tty)
{
struct usb_serial_port *port = tty->driver_data;
+ struct keyspan_pda_private *priv = usb_get_serial_port_data(port);
+ bool throttled;
+ int ret;
- /* just restart the receive interrupt URB */
- if (usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL))
- dev_dbg(&port->dev, "usb_submit_urb(read urb) failed\n");
+ spin_lock_irq(&port->lock);
+ throttled = priv->throttled;
+ priv->throttled = false;
+ priv->throttle_req = false;
+ spin_unlock_irq(&port->lock);
+
+ if (throttled) {
+ ret = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
+ if (ret)
+ dev_err(&port->dev, "failed to submit in urb: %d\n", ret);
+ }
}
static speed_t keyspan_pda_setbaud(struct usb_serial *serial, speed_t baud)
@@ -577,6 +601,8 @@ static int keyspan_pda_open(struct tty_struct *tty,
spin_lock_irq(&port->lock);
priv->tx_room = rc;
+ priv->throttled = false;
+ priv->throttle_req = false;
spin_unlock_irq(&port->lock);
rc = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
]
|
| 162/2 |
2026/07/31 07:28 |
llm |
history-explorer |
0m
Model:
Tokens:
input: 45651
output: 841
thoughts: 661
Thoughts: **Analyzing the `URB submitted while active` Bug and Kernel Idioms**
Okay, so I'm looking at this issue where we're getting a "URB submitted while active" warning, and it seems the root cause is straightforward: an URB (`rcv_urb`) is left active on an error path within `cxacru_cm()`. The problem is that, when `snd_urb` fails to submit or wait, `cxacru_cm()` isn't properly cleaning up the `rcv_urb`. Later, `cxacru_atm_start()` blithely ignores the error and tries to resubmit it, triggering the warning.
My first thought was to see if this type of bug has been addressed before in the kernel USB subsystem, and sure enough, I found some relevant commits that are directly on point:
* `1be3b77de4eb` ("usb: image: mdc800: kill download URB on timeout")
* `372c93131998` ("USB: yurex: fix control-URB timeout handling")
* `b98d5000c505` ("media: rc: iguanair: handle timeouts")
They all deal with the exact same scenario. An URB is submitted, something goes wrong (timeout, other submission failure), and if the code doesn't explicitly handle the active URB it can trigger the warning later. The common solution is to explicitly call `usb_kill_urb()` in the error path. I noted that these commits are good examples of the correct pattern for preventing this.
It's clear, this is a well-understood pattern in the kernel. The fix is to *always* call `usb_kill_urb()` on the active URB when an error occurs after submission. And, crucially, `usb_kill_urb()` is safe to call even if the URB is already completed or wasn't even submitted in the first place. That makes it perfect for error handling: unconditional calls ensure the URB state is reset.
So, the proposed fix of calling `usb_kill_urb(instance->rcv_urb)` unconditionally in the error path of `cxacru_cm()` is the correct approach and aligns perfectly with these established kernel idioms. This is pretty standard stuff. Let's write the response.
|
| 163/1 |
2026/07/31 07:29 |
action |
kernel-scratch-checkouter |
0m
Results: map[KernelScratchSrc:/app/workdir/cache/tmp/tmp2991086643]
|
| 164/1 |
2026/07/31 07:29 |
loop |
|
22m
|
| 165/2 |
2026/07/31 07:29 |
iteration |
0 |
22m
|
| 166/3 |
2026/07/31 07:29 |
agent |
patch-generator |
4m
Model:
Instruction:
You are an experienced Linux kernel developer tasked with creating a fix for a kernel bug.
You will be given a crash report, an initial explanation of the root cause done by another
kernel expert, and a summary of how similar bugs were fixed in the past.
Use the codeeditor tool to do code edits.
Note: you will not see your changes when looking at the code using codesearch tools.
Use the patch-diff tool to review the modifications you applied.
Your final reply should contain explanation of what you did in the patch and why
(details not present in the initial explanation of the bug).
Your fix must not just prevent the given crash, but also be the best fix for the underlying
root cause from the software engineering point of view. There can be several ways to fix the
same bug. Consider alternatives, and pick the best one. For example, additional checks may be
added at different locations/functions, it's usually better to place them earlier in the
execution to avoid multiple checks at various locations later.
Frequently the same coding mistake is done in several locations in the source code.
Check if your fix should be extended/applied to similar cases around to fix other similar bugs.
But don't go too wide, don't try to fix problems kernel-wide, fix similar issues
in the same file only.
If you are changing post-conditions of a function, consider all callers of the functions,
and if they need to be updated to handle new post-conditions. For example, if you make
a function that previously never returned a NULL, return NULL, consider if callers
need to be updated to handle NULL return value.
If you will end up removing the WARN_ON macro because the condition can legitimately happen,
add a pr_err/dev_err/... (whatever is the macro for printing runtime errors used in the file)
call that logs that the unlikely condition has happened. The pr_err/dev_err/... message
must not include "WARNING" nor "BUG" strings.
Prefer calling several tools at the same time to save round-trips.
Prompt:
The crash that corresponds to the bug is:
cxacru 1-1:1.0: send of cm 0x84 failed (-104)
ATM dev 0: cxacru_atm_start: CHIP_ADSL_LINE_START returned -104
------------[ cut here ]------------
URB ffff88812658d200 submitted while active
WARNING: drivers/usb/core/urb.c:379 at usb_submit_urb+0x79/0x18b0 drivers/usb/core/urb.c:379, CPU#1: kworker/1:1/5258
Modules linked in:
CPU: 1 UID: 0 PID: 5258 Comm: kworker/1:1 Not tainted syzkaller #1 PREEMPT(lazy)
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
Workqueue: usb_hub_wq hub_event
RIP: 0010:usb_submit_urb+0x7c/0x18b0 drivers/usb/core/urb.c:379
Code: 4c 89 f0 48 c1 e8 03 80 3c 28 00 74 08 4c 89 f7 e8 c9 ab f6 fc 49 83 3e 00 74 40 e8 9e 5e 91 fc 48 8d 3d 47 b1 aa 05 48 89 de <67> 48 0f b9 3a b8 f0 ff ff ff eb 11 e8 83 5e 91 fc eb 05 e8 7c 5e
RSP: 0018:ffffc90002476878 EFLAGS: 00010293
RAX: ffffffff84f3e532 RBX: ffff88812658d200 RCX: ffff88812fb42440
RDX: 0000000000000000 RSI: ffff88812658d200 RDI: ffffffff8a9e9680
RBP: dffffc0000000000 R08: 0000000000000002 R09: 0000000000000000
R10: dffffc0000000000 R11: fffffbfff152f477 R12: 0000000000000040
R13: 0000000000000000 R14: ffff88812658d208 R15: 0000000000000cc0
FS: 0000000000000000(0000) GS:ffff8882a9042000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f7be0a0cfe0 CR3: 000000011d54e000 CR4: 0000000000350ef0
Call Trace:
<TASK>
cxacru_cm+0x21a/0xf10 drivers/usb/atm/cxacru.c:631
cxacru_cm_get_array drivers/usb/atm/cxacru.c:722 [inline]
cxacru_poll_status+0x178/0x1110 drivers/usb/atm/cxacru.c:828
cxacru_atm_start+0x185/0x360 drivers/usb/atm/cxacru.c:814
usbatm_atm_init+0x144/0x3a0 drivers/usb/atm/usbatm.c:927
usbatm_usb_probe+0x15cb/0x1db0 drivers/usb/atm/usbatm.c:1178
cxacru_usb_probe+0x17f/0x220 drivers/usb/atm/cxacru.c:1370
usb_probe_interface+0x653/0xc60 drivers/usb/core/driver.c:396
call_driver_probe drivers/base/dd.c:-1 [inline]
really_probe+0x254/0xae0 drivers/base/dd.c:706
__driver_probe_device+0x1e8/0x360 drivers/base/dd.c:868
driver_probe_device+0x4f/0x240 drivers/base/dd.c:898
__device_attach_driver+0x270/0x410 drivers/base/dd.c:1026
bus_for_each_drv+0x258/0x2f0 drivers/base/bus.c:500
__device_attach+0x2c4/0x450 drivers/base/dd.c:1098
device_initial_probe+0xa1/0xd0 drivers/base/dd.c:1153
bus_probe_device+0x12a/0x220 drivers/base/bus.c:620
device_add+0x7d7/0xb80 drivers/base/core.c:3772
usb_set_configuration+0x1ad8/0x2180 drivers/usb/core/message.c:2268
usb_generic_driver_probe+0x8d/0x150 drivers/usb/core/generic.c:250
usb_probe_device+0x1c3/0x3b0 drivers/usb/core/driver.c:291
call_driver_probe drivers/base/dd.c:-1 [inline]
really_probe+0x254/0xae0 drivers/base/dd.c:706
__driver_probe_device+0x1e8/0x360 drivers/base/dd.c:868
driver_probe_device+0x4f/0x240 drivers/base/dd.c:898
__device_attach_driver+0x270/0x410 drivers/base/dd.c:1026
bus_for_each_drv+0x258/0x2f0 drivers/base/bus.c:500
__device_attach+0x2c4/0x450 drivers/base/dd.c:1098
device_initial_probe+0xa1/0xd0 drivers/base/dd.c:1153
bus_probe_device+0x12a/0x220 drivers/base/bus.c:620
device_add+0x7d7/0xb80 drivers/base/core.c:3772
usb_new_device+0x99d/0x1620 drivers/usb/core/hub.c:2695
hub_port_connect drivers/usb/core/hub.c:5567 [inline]
hub_port_connect_change drivers/usb/core/hub.c:5707 [inline]
port_event drivers/usb/core/hub.c:5871 [inline]
hub_event+0x28e8/0x4d30 drivers/usb/core/hub.c:5953
process_one_work kernel/workqueue.c:3322 [inline]
process_scheduled_works+0xa8e/0x14e0 kernel/workqueue.c:3405
worker_thread+0x92d/0xe10 kernel/workqueue.c:3486
kthread+0x388/0x470 kernel/kthread.c:436
ret_from_fork+0x491/0xad0 arch/x86/kernel/process.c:158
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
</TASK>
----------------
Code disassembly (best guess):
0: 4c 89 f0 mov %r14,%rax
3: 48 c1 e8 03 shr $0x3,%rax
7: 80 3c 28 00 cmpb $0x0,(%rax,%rbp,1)
b: 74 08 je 0x15
d: 4c 89 f7 mov %r14,%rdi
10: e8 c9 ab f6 fc call 0xfcf6abde
15: 49 83 3e 00 cmpq $0x0,(%r14)
19: 74 40 je 0x5b
1b: e8 9e 5e 91 fc call 0xfc915ebe
20: 48 8d 3d 47 b1 aa 05 lea 0x5aab147(%rip),%rdi # 0x5aab16e
27: 48 89 de mov %rbx,%rsi
* 2a: 67 48 0f b9 3a ud1 (%edx),%rdi <-- trapping instruction
2f: b8 f0 ff ff ff mov $0xfffffff0,%eax
34: eb 11 jmp 0x47
36: e8 83 5e 91 fc call 0xfc915ebe
3b: eb 05 jmp 0x42
3d: e8 .byte 0xe8
3e: 7c 5e jl 0x9e
The explanation of the root cause of the bug is:
The root cause of this bug is that `cxacru_cm()` leaves `rcv_urb` active if it encounters an error while submitting or waiting for `snd_urb`.
Here is the exact sequence of events that leads to the crash:
1. `cxacru_atm_start()` calls `cxacru_cm()` to send the `CM_REQUEST_CHIP_ADSL_LINE_START` (`0x84`) command.
2. Inside `cxacru_cm()`, `rcv_urb` is successfully submitted first (line 631).
3. Then, `snd_urb` is submitted and `cxacru_cm()` waits for its completion via `cxacru_start_wait_urb()` (line 657).
4. In the syzkaller reproducer, the USB device behaves unexpectedly (e.g., endpoint stall or disconnect), causing `snd_urb` to complete with an error status of `-104` (`-ECONNRESET`).
5. `cxacru_start_wait_urb()` returns this `-104` error, which prompts `cxacru_cm()` to print `"send of cm 0x84 failed (-104)"` and jump to the `fail:` label (line 661).
6. At the `fail:` label, `cxacru_cm()` simply unlocks the mutex and returns the error, **leaving `rcv_urb` still active and pending**.
7. Back in `cxacru_atm_start()`, the error is printed (`"CHIP_ADSL_LINE_START returned -104"`) but ignored, and the driver proceeds to start status polling by calling `cxacru_poll_status()`.
8. `cxacru_poll_status()` immediately calls `cxacru_cm_get_array()`, which invokes `cxacru_cm()` again.
9. `cxacru_cm()` attempts to submit `rcv_urb` again, but since it was never unlinked or waited for in the previous failed call, it is still active. This triggers the `URB ... submitted while active` warning in `usb_submit_urb()`.
### Fix
To fix this bug, we need to ensure that `rcv_urb` is properly killed if `cxacru_cm()` aborts early. We can safely call `usb_kill_urb()` on `rcv_urb` in the error path. `usb_kill_urb()` is safe to call even if the URB is not active (e.g., if it failed to submit in the first place, or if it already completed), so it can be called unconditionally on error.
```c
--- a/drivers/usb/atm/cxacru.c
+++ b/drivers/usb/atm/cxacru.c
@@ -700,6 +700,8 @@ static int cxacru_cm(struct cxacru_data *instance, enum cxacru_cm_request cm,
ret = offd;
usb_dbg(instance->usbatm, "cm %#x\n", cm);
fail:
+ if (ret < 0)
+ usb_kill_urb(instance->rcv_urb);
mutex_unlock(&instance->cm_serialize);
err:
return ret;
```
Historical context on how similar bugs were fixed in the past:
Based on a thorough research of the kernel history, here is a summary of the findings regarding similar bugs and the established idioms for fixing them.
### Root Cause Context
The bug occurs because `cxacru_cm()` submits `rcv_urb`, but if the subsequent submission or wait for `snd_urb` fails, it returns an error while leaving `rcv_urb` active. The caller `cxacru_atm_start()` ignores this error (a behavior introduced in historical commit `fd209e35b741` *"USB: cxacru: ignore error trying to start ADSL in atm_start"*) and proceeds to poll the status. This polling invokes `cxacru_cm()` again, which attempts to resubmit the still-active `rcv_urb`, triggering the `URB submitted while active` warning.
### Prior Art and Similar Fixes
While there are no recent commits in `drivers/usb/atm/` addressing this specific URB cleanup issue, a broader search across the USB and media subsystems reveals that this is a known anti-pattern. Several commits have addressed the exact same root cause (leaving an URB active on an error/timeout path):
1. **`1be3b77de4eb` ("usb: image: mdc800: kill download URB on timeout")**
The driver submitted an URB and waited for completion. On timeout, it returned an error but left the URB active. A subsequent read attempted to resubmit it, triggering the same warning. The fix was to explicitly call `usb_kill_urb()` on the timeout error path.
2. **`372c93131998` ("USB: yurex: fix control-URB timeout handling")**
Similar to the above, the driver failed to cancel a control URB on timeout. The fix ensured `usb_kill_urb()` was called so the URB could be safely reused on the next write request.
3. **`b98d5000c505` ("media: rc: iguanair: handle timeouts")**
The driver waited for a completion after sending a command. On timeout, it returned `-ETIMEDOUT` but left the `urb_out` active, causing subsequent IO to fail. The fix added `usb_kill_urb()` to the timeout path.
### Idioms and Common Patterns to Follow
Based on how previous similar bugs were addressed, the following rules and patterns should be applied when writing a fix for this bug:
1. **Explicit URB Cleanup on Error Paths:** Whenever a function submits one or more URBs and then encounters an error (e.g., a timeout, a failure in a subsequent operation, or a failure in waiting for another URB), it **must** explicitly cancel any successfully submitted URBs before returning.
2. **Use of `usb_kill_urb()`:** The standard idiom for this cleanup is to use `usb_kill_urb()`. This function synchronously cancels the URB and waits for its completion handler to finish.
3. **Unconditional Cleanup is Safe:** `usb_kill_urb()` is safe to call even if the URB is not currently active (e.g., if it failed to submit in the first place, or if it already completed successfully). This makes it robust for unconditional use in a unified `fail:` or `err:` cleanup block at the end of a function.
### Conclusion
Your proposed fix perfectly aligns with the established kernel idioms. By unconditionally calling `usb_kill_urb(instance->rcv_urb)` in the `fail:` path of `cxacru_cm()`, you ensure that the URB is fully canceled and its state is reset. This guarantees that subsequent calls to `cxacru_cm()` (even if the error was ignored by the caller) will start with a clean state, preventing the `URB submitted while active` warning.
Reply: The root cause of this bug is that `cxacru_cm()` leaves `rcv_urb` active if it encounters an error while submitting or waiting for `snd_urb`.
Here is the exact sequence of events that leads to the crash:
1. `cxacru_atm_start()` calls `cxacru_cm()` to send the `CM_REQUEST_CHIP_ADSL_LINE_START` command.
2. Inside `cxacru_cm()`, `rcv_urb` is successfully submitted first.
3. Then, `snd_urb` is submitted and `cxacru_cm()` waits for its completion via `cxacru_start_wait_urb()`.
4. If the USB device behaves unexpectedly, `snd_urb` completes with an error status (e.g., `-104`).
5. `cxacru_start_wait_urb()` returns this error, which prompts `cxacru_cm()` to jump to the `fail:` label.
6. At the `fail:` label, `cxacru_cm()` simply unlocks the mutex and returns the error, leaving `rcv_urb` still active and pending.
7. Back in `cxacru_atm_start()`, the error is ignored, and the driver proceeds to start status polling by calling `cxacru_poll_status()`.
8. `cxacru_poll_status()` immediately calls `cxacru_cm_get_array()`, which invokes `cxacru_cm()` again.
9. `cxacru_cm()` attempts to submit `rcv_urb` again, but since it was never unlinked or waited for in the previous failed call, it is still active. This triggers the `URB ... submitted while active` warning in `usb_submit_urb()`.
To fix this bug, we need to ensure that `rcv_urb` is properly killed if `cxacru_cm()` aborts early. We can safely call `usb_kill_urb()` on `rcv_urb` in the error path. `usb_kill_urb()` is safe to call even if the URB is not active (e.g., if it failed to submit in the first place, or if it already completed), so it can be called unconditionally on error.
Note that we don't need to do the same for `snd_urb` because `cxacru_start_wait_urb()` uses `wait_for_completion()` which is uninterruptible, meaning it will always wait until the URB completes (either successfully, with an error, or by timing out and being unlinked). Thus, `snd_urb` is never left active when `cxacru_start_wait_urb()` returns.
I have applied the fix using the `codeeditor` tool. The patch adds `usb_kill_urb(instance->rcv_urb)` in the `fail:` path of `cxacru_cm()` if `ret < 0`. This guarantees that subsequent calls to `cxacru_cm()` will start with a clean state, preventing the `URB submitted while active` warning.
|
| 167/4 |
2026/07/31 07:29 |
llm |
patch-generator |
0m
Model:
Tokens:
input: 8575
output: 40
thoughts: 140
Thoughts: **Debugging a USB ATM Driver Issue**
Okay, so I'm digging into this `cxacru.c` file β specifically, the `cxacru_cm()` function within the `drivers/usb/atm` directory. It seems like we have a pretty nasty bug here, a race condition really, related to how we handle URBs (USB Request Blocks). My initial reading is that the issue is when we encounter an error while either submitting or waiting for `snd_urb`. The problem is that if `cxacru_cm()` hits an error in that scenario, it leaves `rcv_urb` active.
The crash occurs later, when `cxacru_cm()` is called again and tries to submit `rcv_urb` while the USB subsystem is saying it's already active. Not good. I can see that happening, of course.
The proposed fix makes immediate sense. The idea is to jump to a "fail:" label and issue `usb_kill_urb(instance->rcv_urb)` if `ret < 0` meaning any type of error was encountered. That should ensure that the `rcv_urb` is properly cleaned up before re-use. This seems like a reasonable approach to address the resource contention. Now let me take a closer look at the relevant code in `cxacru_cm()` and confirm this fix addresses the root cause correctly.
|
| 168/4 |
2026/07/31 07:29 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/usb/atm/cxacru.c Name:cxacru_cm]
Results: map[SourceCode: 608: static int cxacru_cm(struct cxacru_data *instance, enum cxacru_cm_request cm,
609: u8 *wdata, int wsize, u8 *rdata, int rsize)
610: {
611: int ret, actlen;
612: int offb, offd;
613: const int stride = CMD_PACKET_SIZE - 4;
614: u8 *wbuf = instance->snd_buf;
615: u8 *rbuf = instance->rcv_buf;
616: int wbuflen = ((wsize - 1) / stride + 1) * CMD_PACKET_SIZE;
617: int rbuflen = ((rsize - 1) / stride + 1) * CMD_PACKET_SIZE;
618:
619: if (wbuflen > PAGE_SIZE || rbuflen > PAGE_SIZE) {
620: if (printk_ratelimit())
621: usb_err(instance->usbatm, "requested transfer size too large (%d, %d)\n",
622: wbuflen, rbuflen);
623: ret = -ENOMEM;
624: goto err;
625: }
626:
627: mutex_lock(&instance->cm_serialize);
628:
629: /* submit reading urb before the writing one */
630: init_completion(&instance->rcv_done);
631: ret = usb_submit_urb(instance->rcv_urb, GFP_KERNEL);
632: if (ret < 0) {
633: if (printk_ratelimit())
634: usb_err(instance->usbatm, "submit of read urb for cm %#x failed (%d)\n",
635: cm, ret);
636: goto fail;
637: }
638:
639: memset(wbuf, 0, wbuflen);
640: /* handle wsize == 0 */
641: wbuf[0] = cm;
642: for (offb = offd = 0; offd < wsize; offd += stride, offb += CMD_PACKET_SIZE) {
643: wbuf[offb] = cm;
644: memcpy(wbuf + offb + 4, wdata + offd, min_t(int, stride, wsize - offd));
645: }
646:
647: instance->snd_urb->transfer_buffer_length = wbuflen;
648: init_completion(&instance->snd_done);
649: ret = usb_submit_urb(instance->snd_urb, GFP_KERNEL);
650: if (ret < 0) {
651: if (printk_ratelimit())
652: usb_err(instance->usbatm, "submit of write urb for cm %#x failed (%d)\n",
653: cm, ret);
654: goto fail;
655: }
656:
657: ret = cxacru_start_wait_urb(instance->snd_urb, &instance->snd_done, NULL);
658: if (ret < 0) {
659: if (printk_ratelimit())
660: usb_err(instance->usbatm, "send of cm %#x failed (%d)\n", cm, ret);
661: goto fail;
662: }
663:
664: ret = cxacru_start_wait_urb(instance->rcv_urb, &instance->rcv_done, &actlen);
665: if (ret < 0) {
666: if (printk_ratelimit())
667: usb_err(instance->usbatm, "receive of cm %#x failed (%d)\n", cm, ret);
668: goto fail;
669: }
670: if (actlen % CMD_PACKET_SIZE || !actlen) {
671: if (printk_ratelimit())
672: usb_err(instance->usbatm, "invalid response length to cm %#x: %d\n",
673: cm, actlen);
674: ret = -EIO;
675: goto fail;
676: }
677:
678: /* check the return status and copy the data to the output buffer, if needed */
679: for (offb = offd = 0; offd < rsize && offb < actlen; offb += CMD_PACKET_SIZE) {
680: if (rbuf[offb] != cm) {
681: if (printk_ratelimit())
682: usb_err(instance->usbatm, "wrong cm %#x in response to cm %#x\n",
683: rbuf[offb], cm);
684: ret = -EIO;
685: goto fail;
686: }
687: if (rbuf[offb + 1] != CM_STATUS_SUCCESS) {
688: if (printk_ratelimit())
689: usb_err(instance->usbatm, "response to cm %#x failed: %#x\n",
690: cm, rbuf[offb + 1]);
691: ret = -EIO;
692: goto fail;
693: }
694: if (offd >= rsize)
695: break;
696: memcpy(rdata + offd, rbuf + offb + 4, min_t(int, stride, rsize - offd));
697: offd += stride;
698: }
699:
700: ret = offd;
701: usb_dbg(instance->usbatm, "cm %#x\n", cm);
702: fail:
703: mutex_unlock(&instance->cm_serialize);
704: err:
705: return ret;
706: }
SourceFile:drivers/usb/atm/cxacru.c]
|
| 169/4 |
2026/07/31 07:29 |
llm |
patch-generator |
0m
Model:
Tokens:
input: 10780
output: 44
thoughts: 205
Thoughts: Here's my analysis of the provided code snippet:
**Analyzing the CXACRU Code Fix**
Okay, so they're proposing a change in `cxacru_cm`. Let me quickly look at it... right, the change is adding a call to `usb_kill_urb` before the `mutex_unlock` and error return. This looks like a response to an error in `cxacru_cm`. The logic seems to be: if the command fails (`ret < 0`), *before* releasing the `cm_serialize` mutex and returning, the receiver URB needs to be killed.
The reason is clear: If a low-level USB error happened during the command execution, it's possible the `instance->rcv_urb` is still in a pending state, and not freeing it could lead to resource leaks or unexpected behavior later on. Adding `usb_kill_urb` ensures the receiver URB is properly cleaned up when `cxacru_cm` fails, preventing potential issues with the USB connection.
Now, hold on... does this mean we *also* need to kill `snd_urb` if it fails during submit or wait? `snd_urb` is the *send* URB, and `rcv_urb` is the *receive* URB. The changes only address `rcv_urb`. If `snd_urb` fails in `cxacru_cm` there must be something else going on. Let me go check `cxacru_start_wait_urb` to be sure.
|
| 170/4 |
2026/07/31 07:29 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/usb/atm/cxacru.c Name:cxacru_start_wait_urb]
Results: map[SourceCode: 590: static int cxacru_start_wait_urb(struct urb *urb, struct completion *done,
591: int *actual_length)
592: {
593: struct cxacru_timer timer = {
594: .urb = urb,
595: };
596:
597: timer_setup_on_stack(&timer.timer, cxacru_timeout_kill, 0);
598: mod_timer(&timer.timer, jiffies + msecs_to_jiffies(CMD_TIMEOUT));
599: wait_for_completion(done);
600: timer_delete_sync(&timer.timer);
601: timer_destroy_on_stack(&timer.timer);
602:
603: if (actual_length)
604: *actual_length = urb->actual_length;
605: return urb->status; /* must read status after completion */
606: }
SourceFile:drivers/usb/atm/cxacru.c]
|
| 171/4 |
2026/07/31 07:29 |
llm |
patch-generator |
0m
Model:
Tokens:
input: 11661
output: 42
thoughts: 28
Thoughts: Okay, here's my interpretation of that process, delivered as a first-person expert summary:
**The USB URB Timeout Dilemma**
Alright, so the core of the issue boils down to how we handle USB URB timeouts, specifically when dealing with the `cxacru_start_wait_urb` function. My understanding is that if this particular function sits there waiting for an URB (USB Request Block) to complete for too long, we've got a problem. We can't have the system hanging indefinitely, right? That's where `cxacru_timeout_kill` comes into play. It's essentially our safety net, our emergency brake, our timeout handler.
The logic is straightforward. `cxacru_start_wait_urb` kicks off the process of waiting for the USB request. But if, for whatever reason β a stalled device, a faulty cable, a driver issue, who knows β that request doesn't complete within an acceptable timeframe, *poof* β `cxacru_timeout_kill` is triggered. Its sole purpose is to ruthlessly terminate that hanging URB. This is crucial for avoiding a system lockup, a driver deadlock, or just general instability. It's a fundamental part of robust USB driver design. We need these timeout mechanisms to keep the system responsive. Itβs simple enough, but a necessary component to maintain stability.
|
| 172/4 |
2026/07/31 07:29 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/usb/atm/cxacru.c Name:cxacru_timeout_kill]
Results: map[SourceCode: 583: static void cxacru_timeout_kill(struct timer_list *t)
584: {
585: struct cxacru_timer *timer = timer_container_of(timer, t, timer);
586:
587: usb_unlink_urb(timer->urb);
588: }
SourceFile:drivers/usb/atm/cxacru.c]
|
| 173/4 |
2026/07/31 07:29 |
llm |
patch-generator |
0m
Model:
Tokens:
input: 12154
output: 23
thoughts: 1347
Thoughts: **Analyzing URB State Transitions in Error Paths**
Okay, let's break this down meticulously. My primary concern is ensuring that URBs (USB Request Blocks) are properly cleaned up, i.e., not left in an active state when an error occurs. The goal here is resource management, and preventing any potential double-free or race conditions.
First, I see the cases where an error during the URB transfer means the URB has completed (with an error), and so is no longer active. If `cxacru_start_wait_urb` fails (indicating the URB completed with an error, e.g., `urb->status` is set), then that URB is no longer active. If the `snd_urb` fails to submit, it's not active. Same with the `rcv_urb` wait failing or if there are invalid data lengths.
Now, the trickier scenarios: If `snd_urb` submits, and `cxacru_start_wait_urb` *then* fails (maybe a -104 error), then `snd_urb` *has* completed, but the `rcv_urb` is still active. I see the importance of ensuring the other URB is cleaned up in this situation.
If the `snd_urb` wait succeeds, but the `rcv_urb` wait fails... then the `rcv_urb` is finished, so it is no longer active. But if `snd_urb` fails to submit, the `rcv_urb` is still active. If `snd_urb` wait fails, the `rcv_urb` is active.
So calling `usb_kill_urb(instance->rcv_urb)` in the `fail:` path when `ret < 0` seems safe and correct. Good!
Let's carefully consider `snd_urb`.
If `usb_submit_urb(instance->snd_urb)` fails, it's not active.
If `cxacru_start_wait_urb(instance->snd_urb)` is called, it waits for completion. So, it is not active.
Therefore, `snd_urb` should never be active when we jump to `fail:`. Excellent!
Wait, what about timeouts? `cxacru_timeout_kill` calls `usb_unlink_urb`. But is `cxacru_start_wait_urb` synchronous? Yes, it uses `wait_for_completion` after `usb_unlink_urb` which *does* wait for the completion handler. This is good because it guarantees that `snd_urb` will be completed when `cxacru_start_wait_urb` returns, even with timeouts. The check in the timer function confirms this. Even if it's interrupted, `wait_for_completion` won't return until the URB is finished. Good.
What about `rcv_urb`? It seems like it could be active in the case where we jump to `fail:` before calling `cxacru_start_wait_urb` on it. If we call `usb_kill_urb`, we cancel and wait for its completion. This is the crucial point.
`usb_kill_urb` waits for completion, but what about the signal? The completion handler signals `instance->rcv_done`, but we don't *wait* for `instance->rcv_done` in the error path. Okay, but `init_completion` is called in the next invocation so that's fine.
Double checking `snd_urb` again. If submission fails, it's not active. If it waits, it's not active. So it should never be active at `fail:`.
What if `usb_submit_urb(instance->rcv_urb)` fails? We jump to `fail:` and call `usb_kill_urb(instance->rcv_urb)`. Is that safe on an unsubmitted URB? Yes, according to the documentation. "It is safe to call this routine if @urb is unlinked or not submitted." Great!
What if `snd_urb` submits and errors during wait? `rcv_urb` is active; `usb_kill_urb(instance->rcv_urb)` cancels it. Correct.
Okay, I've covered all the scenarios now, and confirmed there are only two URBs. It appears that no URBs are left active in the failure paths. I've re-examined where each URB is set in an active state, and where each one could be cleaned. It's safe to call `usb_kill_urb` in any failure case. I feel good about this analysis.
|
| 174/4 |
2026/07/31 07:30 |
tool |
codesearch-find-references |
0m
Args:
Results: map[References:[map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:adsl_config_store SourceFile:drivers/usb/atm/cxacru.c SourceLine:481] map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:adsl_state_store SourceFile:drivers/usb/atm/cxacru.c SourceLine:357] map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:adsl_state_store SourceFile:drivers/usb/atm/cxacru.c SourceLine:377] map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:cxacru_atm_start SourceFile:drivers/usb/atm/cxacru.c SourceLine:780] map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:cxacru_atm_start SourceFile:drivers/usb/atm/cxacru.c SourceLine:789] map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:cxacru_card_status SourceFile:drivers/usb/atm/cxacru.c SourceLine:760] map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:cxacru_cm_get_array SourceFile:drivers/usb/atm/cxacru.c SourceLine:722] map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:cxacru_heavy_init SourceFile:drivers/usb/atm/cxacru.c SourceLine:1100]] TruncatedOutput:false]
|
| 175/4 |
2026/07/31 07:30 |
llm |
patch-generator |
0m
Model:
Tokens:
input: 14982
output: 44
thoughts: 15
Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience, and delivered as a first-person summary:
**Digging into `cxacru_cm_get_array`**
Alright, time to dive into this. Let's start by zeroing in on `cxacru_cm_get_array`. That function call immediately piques my interest. It implies we're dealing with retrieving an array structure, likely within the context of the `cxacru` module, which Iβm familiar with. Given the naming convention, I suspect it's responsible for fetching an array of configuration parameters, possibly sensor data, or some critical values for this system. Iβm already mentally mapping out where in the code I've seen similar functions and thinking about potential error conditions I need to keep in mind, like null pointers or bounds checks when accessing the array elements. I need to understand its intended purpose and interface constraints. I'm going to have to see how this function handles things like: is the array dynamically allocated? Is there memory management involved, and if so, where does it live in our code. What are the calling conventions? Is it thread-safe, and if so, how is that achieved? A review of this function is in order.
|
| 176/4 |
2026/07/31 07:30 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/usb/atm/cxacru.c Name:cxacru_cm_get_array]
Results: map[SourceCode: 708: static int cxacru_cm_get_array(struct cxacru_data *instance, enum cxacru_cm_request cm,
709: u32 *data, int size)
710: {
711: int ret, len;
712: __le32 *buf;
713: int offb;
714: unsigned int offd;
715: const int stride = CMD_PACKET_SIZE / (4 * 2) - 1;
716: int buflen = ((size - 1) / stride + 1 + size * 2) * 4;
717:
718: buf = kmalloc(buflen, GFP_KERNEL);
719: if (!buf)
720: return -ENOMEM;
721:
722: ret = cxacru_cm(instance, cm, NULL, 0, (u8 *) buf, buflen);
723: if (ret < 0)
724: goto cleanup;
725:
726: /* len > 0 && len % 4 == 0 guaranteed by cxacru_cm() */
727: len = ret / 4;
728: for (offb = 0; offb < len; ) {
729: int l = le32_to_cpu(buf[offb++]);
730:
731: if (l < 0 || l > stride || l > (len - offb) / 2) {
732: if (printk_ratelimit())
733: usb_err(instance->usbatm, "invalid data length from cm %#x: %d\n",
734: cm, l);
735: ret = -EIO;
736: goto cleanup;
737: }
738: while (l--) {
739: offd = le32_to_cpu(buf[offb++]);
740: if (offd >= size) {
741: if (printk_ratelimit())
742: usb_err(instance->usbatm, "wrong index %#x in response to cm %#x\n",
743: offd, cm);
744: ret = -EIO;
745: goto cleanup;
746: }
747: data[offd] = le32_to_cpu(buf[offb++]);
748: }
749: }
750:
751: ret = 0;
752:
753: cleanup:
754: kfree(buf);
755: return ret;
756: }
SourceFile:drivers/usb/atm/cxacru.c]
|
| 177/4 |
2026/07/31 07:30 |
llm |
patch-generator |
0m
Model:
Tokens:
input: 16102
output: 36
thoughts: 19
Thoughts: Here's my thought process, as if I were analyzing that code:
**Checking for More URBs**
Okay, so I'm looking at `cxacru.c`. The first thing I want to know is, are there any other URBs (USB Request Blocks) in this file besides the ones I'm already aware of? It's pretty crucial to know the complete scope of USB communication within this module. I need to make sure I'm not missing anything critical in my analysis of the USB implementation here, and I suspect there are more to find. This is a common pattern, and I'm just quickly scanning the file to verify this. I'm hoping I don't overlook any, because that would mean needing to come back and review. So, let's see what's in this file...
|
| 178/4 |
2026/07/31 07:30 |
tool |
grepper |
0m
Args: map[Expression:usb_submit_urb PathPrefix:drivers/usb/atm/cxacru.c]
Results: map[Output:drivers/usb/atm/cxacru.c=608=static int cxacru_cm(struct cxacru_data *instance, enum cxacru_cm_request cm,
--
drivers/usb/atm/cxacru.c-630- init_completion(&instance->rcv_done);
drivers/usb/atm/cxacru.c:631: ret = usb_submit_urb(instance->rcv_urb, GFP_KERNEL);
drivers/usb/atm/cxacru.c-632- if (ret < 0) {
--
drivers/usb/atm/cxacru.c-648- init_completion(&instance->snd_done);
drivers/usb/atm/cxacru.c:649: ret = usb_submit_urb(instance->snd_urb, GFP_KERNEL);
drivers/usb/atm/cxacru.c-650- if (ret < 0) {
]
|
| 179/4 |
2026/07/31 07:30 |
llm |
patch-generator |
0m
Model:
Tokens:
input: 16573
output: 22
thoughts: 468
Thoughts: **Analyzing URB Handling in `cxacru.c`**
Okay, so I'm focusing on the URB submission and handling within the `cxacru.c` driver, specifically `rcv_urb` and `snd_urb`. I need to ensure proper error recovery. I recall `usbatm.c` *might* submit URBs too, but for the core logic, `cxacru.c` is the key.
First, I'm checking the dependencies. If `rcv_urb` fails during submission (at line 631), `snd_urb` hasn't even been submitted, so nothing to kill there. But if `snd_urb` fails to submit (at line 649), `rcv_urb` is active, and the code jumps to the `fail:` label. The proposed fix there is to kill `rcv_urb`, which seems logical.
Now, if the `snd_urb`'s wait operation fails (at line 657), it implies `snd_urb` has completed, and `rcv_urb` is still active. Again, we jump to `fail:` and the fix is to kill `rcv_urb`. That's expected. If `rcv_urb`'s wait fails (at line 664), both URBs are done, and we're again at `fail:`. Safe to kill `rcv_urb`. Similarly, if `rcv_urb` wait succeeds but the received data is invalid (lines 670, 680, 687), it's the same scenario, `snd_urb` and `rcv_urb` have completed, so killing `rcv_urb` is safe.
Now, the tricky part... what if `snd_urb` wait succeeds but `rcv_urb` wait fails? I need to confirm that `snd_urb` is indeed guaranteed to have completed in that scenario. Yes, `cxacru_start_wait_urb` *does* wait for its completion.
I'm confident I've got the relevant URBs now. I'm not seeing any other URBs that require attention in this specific error flow.
Next step: I'm verifying that `usb_kill_urb` is the appropriate function to use for cleanup here. Ah yes, it's synchronous and waits for the completion handler. That's good. And since I'm holding the `instance->cm_serialize` mutex, and the completion handler doesn't take this same mutex, I'm confident there's no potential deadlock here. So, I need to check the completion handler code to be sure.
|
| 180/4 |
2026/07/31 07:30 |
tool |
codesearch-find-references |
0m
Error:
Args:
Results: map[References:<nil> TruncatedOutput:false]
|
| 181/4 |
2026/07/31 07:30 |
llm |
patch-generator |
0m
Model:
Tokens:
input: 17660
output: 35
thoughts: 14
Thoughts: Okay, here's my attempt at summarizing that thought process, keeping in mind I'm speaking to a fellow expert:
**Finding the `rcv_urb` Completion Handler**
Alright, so the first thing on my mind is, "Where's the completion handler for `rcv_urb`?" Specifically, what function or code block is responsible for processing the data after a USB receive URB (USB Request Block) completes? I need to find that handler. I'm going to start by tracing the function calls associated with that URB and zeroing in on the part that deals with its completion to figure out where things are passed. What is the architecture here? I'm going to follow the flow of data and see if I can't find the completion callback, and identify any interactions that it triggers.
|
| 182/4 |
2026/07/31 07:30 |
tool |
grepper |
0m
Args: map[Expression:rcv_urb PathPrefix:drivers/usb/atm/cxacru.c]
Results: map[Output:drivers/usb/atm/cxacru.c=170=struct cxacru_data {
--
drivers/usb/atm/cxacru.c-186- u8 *snd_buf;
drivers/usb/atm/cxacru.c:187: struct urb *rcv_urb;
drivers/usb/atm/cxacru.c-188- struct urb *snd_urb;
--
drivers/usb/atm/cxacru.c=608=static int cxacru_cm(struct cxacru_data *instance, enum cxacru_cm_request cm,
--
drivers/usb/atm/cxacru.c-630- init_completion(&instance->rcv_done);
drivers/usb/atm/cxacru.c:631: ret = usb_submit_urb(instance->rcv_urb, GFP_KERNEL);
drivers/usb/atm/cxacru.c-632- if (ret < 0) {
--
drivers/usb/atm/cxacru.c-663-
drivers/usb/atm/cxacru.c:664: ret = cxacru_start_wait_urb(instance->rcv_urb, &instance->rcv_done, &actlen);
drivers/usb/atm/cxacru.c-665- if (ret < 0) {
--
drivers/usb/atm/cxacru.c=1120=static int cxacru_bind(struct usbatm_data *usbatm_instance,
--
drivers/usb/atm/cxacru.c-1158- }
drivers/usb/atm/cxacru.c:1159: instance->rcv_urb = usb_alloc_urb(0, GFP_KERNEL);
drivers/usb/atm/cxacru.c:1160: if (!instance->rcv_urb) {
drivers/usb/atm/cxacru.c-1161- ret = -ENOMEM;
--
drivers/usb/atm/cxacru.c-1188- == USB_ENDPOINT_XFER_INT) {
drivers/usb/atm/cxacru.c:1189: usb_fill_int_urb(instance->rcv_urb,
drivers/usb/atm/cxacru.c-1190- usb_dev, usb_rcvintpipe(usb_dev, CXACRU_EP_CMD),
--
drivers/usb/atm/cxacru.c-1198- } else {
drivers/usb/atm/cxacru.c:1199: usb_fill_bulk_urb(instance->rcv_urb,
drivers/usb/atm/cxacru.c-1200- usb_dev, usb_rcvbulkpipe(usb_dev, CXACRU_EP_CMD),
--
drivers/usb/atm/cxacru.c-1223- usb_free_urb(instance->snd_urb);
drivers/usb/atm/cxacru.c:1224: usb_free_urb(instance->rcv_urb);
drivers/usb/atm/cxacru.c-1225- kfree(instance);
--
drivers/usb/atm/cxacru.c=1230=static void cxacru_unbind(struct usbatm_data *usbatm_instance,
--
drivers/usb/atm/cxacru.c-1258- usb_kill_urb(instance->snd_urb);
drivers/usb/atm/cxacru.c:1259: usb_kill_urb(instance->rcv_urb);
drivers/usb/atm/cxacru.c-1260- usb_free_urb(instance->snd_urb);
drivers/usb/atm/cxacru.c:1261: usb_free_urb(instance->rcv_urb);
drivers/usb/atm/cxacru.c-1262-
]
|
| 183/4 |
2026/07/31 07:30 |
llm |
patch-generator |
0m
Model:
Tokens:
input: 18868
output: 40
thoughts: 17
Thoughts: Here's a summary of my thought process:
**Diving into `cxacru_bind`**
Okay, so I need to understand how this `cxacru_bind` function works. My primary focus right now is on the completion handler. I need to trace the flow and see precisely where the completion routine is defined and invoked. That's where the real magic happens, so I need to find the specific section that executes after the binding operation completes. Let's see how that callback is defined and utilized within `cxacru_bind`. Time to dive in!
|
| 184/4 |
2026/07/31 07:31 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/usb/atm/cxacru.c Name:cxacru_bind]
Results: map[SourceCode:1120: static int cxacru_bind(struct usbatm_data *usbatm_instance,
1121: struct usb_interface *intf, const struct usb_device_id *id)
1122: {
1123: struct cxacru_data *instance;
1124: struct usb_device *usb_dev = interface_to_usbdev(intf);
1125: struct usb_host_endpoint *cmd_ep = usb_dev->ep_in[CXACRU_EP_CMD];
1126: static const u8 ep_addrs[] = {
1127: CXACRU_EP_CMD + USB_DIR_IN,
1128: CXACRU_EP_CMD + USB_DIR_OUT,
1129: 0};
1130: int ret;
1131:
1132: /* instance init */
1133: instance = kzalloc_obj(*instance);
1134: if (!instance)
1135: return -ENOMEM;
1136:
1137: instance->usbatm = usbatm_instance;
1138: instance->modem_type = (struct cxacru_modem_type *) id->driver_info;
1139:
1140: mutex_init(&instance->poll_state_serialize);
1141: instance->poll_state = CXPOLL_STOPPED;
1142: instance->line_status = -1;
1143: instance->adsl_status = -1;
1144:
1145: mutex_init(&instance->adsl_state_serialize);
1146:
1147: instance->rcv_buf = (u8 *) __get_free_page(GFP_KERNEL);
1148: if (!instance->rcv_buf) {
1149: usb_dbg(usbatm_instance, "cxacru_bind: no memory for rcv_buf\n");
1150: ret = -ENOMEM;
1151: goto fail;
1152: }
1153: instance->snd_buf = (u8 *) __get_free_page(GFP_KERNEL);
1154: if (!instance->snd_buf) {
1155: usb_dbg(usbatm_instance, "cxacru_bind: no memory for snd_buf\n");
1156: ret = -ENOMEM;
1157: goto fail;
1158: }
1159: instance->rcv_urb = usb_alloc_urb(0, GFP_KERNEL);
1160: if (!instance->rcv_urb) {
1161: ret = -ENOMEM;
1162: goto fail;
1163: }
1164: instance->snd_urb = usb_alloc_urb(0, GFP_KERNEL);
1165: if (!instance->snd_urb) {
1166: ret = -ENOMEM;
1167: goto fail;
1168: }
1169:
1170: if (!cmd_ep) {
1171: usb_dbg(usbatm_instance, "cxacru_bind: no command endpoint\n");
1172: ret = -ENODEV;
1173: goto fail;
1174: }
1175:
1176: if (usb_endpoint_xfer_int(&cmd_ep->desc))
1177: ret = usb_check_int_endpoints(intf, ep_addrs);
1178: else
1179: ret = usb_check_bulk_endpoints(intf, ep_addrs);
1180:
1181: if (!ret) {
1182: usb_err(usbatm_instance, "cxacru_bind: interface has incorrect endpoints\n");
1183: ret = -ENODEV;
1184: goto fail;
1185: }
1186:
1187: if ((cmd_ep->desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK)
1188: == USB_ENDPOINT_XFER_INT) {
1189: usb_fill_int_urb(instance->rcv_urb,
1190: usb_dev, usb_rcvintpipe(usb_dev, CXACRU_EP_CMD),
1191: instance->rcv_buf, PAGE_SIZE,
1192: cxacru_blocking_completion, &instance->rcv_done, 1);
1193:
1194: usb_fill_int_urb(instance->snd_urb,
1195: usb_dev, usb_sndintpipe(usb_dev, CXACRU_EP_CMD),
1196: instance->snd_buf, PAGE_SIZE,
1197: cxacru_blocking_completion, &instance->snd_done, 4);
1198: } else {
1199: usb_fill_bulk_urb(instance->rcv_urb,
1200: usb_dev, usb_rcvbulkpipe(usb_dev, CXACRU_EP_CMD),
1201: instance->rcv_buf, PAGE_SIZE,
1202: cxacru_blocking_completion, &instance->rcv_done);
1203:
1204: usb_fill_bulk_urb(instance->snd_urb,
1205: usb_dev, usb_sndbulkpipe(usb_dev, CXACRU_EP_CMD),
1206: instance->snd_buf, PAGE_SIZE,
1207: cxacru_blocking_completion, &instance->snd_done);
1208: }
1209:
1210: mutex_init(&instance->cm_serialize);
1211:
1212: INIT_DELAYED_WORK(&instance->poll_work, cxacru_poll_status);
1213:
1214: usbatm_instance->driver_data = instance;
1215:
1216: usbatm_instance->flags = (cxacru_card_status(instance) ? 0 : UDSL_SKIP_HEAVY_INIT);
1217:
1218: return 0;
1219:
1220: fail:
1221: free_page((unsigned long) instance->snd_buf);
1222: free_page((unsigned long) instance->rcv_buf);
1223: usb_free_urb(instance->snd_urb);
1224: usb_free_urb(instance->rcv_urb);
1225: kfree(instance);
1226:
1227: return ret;
1228: }
SourceFile:drivers/usb/atm/cxacru.c]
|
| 185/4 |
2026/07/31 07:31 |
llm |
patch-generator |
0m
Model:
Tokens:
input: 20887
output: 42
thoughts: 13
Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience:
**Analyzing the Completion Handler**
Alright, so the core of this seems to revolve around a specific completion handler. The key identifier here is `cxacru_blocking_completion`. Immediately, my mind starts ticking through the implications. A "blocking" completion handler suggests a few things, depending on the context.
* Is this a synchronous operation?
* Is it related to thread management and resource contention?
* What is the mechanism by which it blocks? Does it use a mutex, a condition variable, a semaphore, or something else entirely?
* What are the failure modes it handles?
My immediate goal is to understand how this `cxacru_blocking_completion` handler fits into the overall system architecture. Is it the primary completion mechanism, or a specialized one? And the biggest question: does it handle timeouts or any special cases or does it rely on external logic? I need to understand its relationship to the asynchronous operations it's completing. What's the potential for deadlocks or race conditions?
I'd want to dive deeper to consider how this particular handler is implemented and how it is actually used and to what this function is specifically applied.
|
| 186/4 |
2026/07/31 07:31 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/usb/atm/cxacru.c Name:cxacru_blocking_completion]
Results: map[SourceCode: 572: /* the following three functions are stolen from drivers/usb/core/message.c */
573: static void cxacru_blocking_completion(struct urb *urb)
574: {
575: complete(urb->context);
576: }
SourceFile:drivers/usb/atm/cxacru.c]
|
| 187/4 |
2026/07/31 07:31 |
llm |
patch-generator |
0m
Model:
Tokens:
input: 21314
output: 166
thoughts: 901
Thoughts: **Analyzing URB Cancellation and Completion in cxacru_cm**
Okay, so I'm looking at this completion handler. It's standard; `usb_kill_urb(instance->rcv_urb)` cancels the URB synchronously, waiting for the completion handler. That handler then calls `complete(&instance->rcv_done)`. Crucially, `cxacru_cm` doesn't explicitly wait for `instance->rcv_done` on the error path (`fail:`). However, the next time `cxacru_cm` is called, it re-initializes `instance->rcv_done` with `init_completion()`, effectively resetting it. So, even though the completion might be "left signaled," it's safe because it's overwritten. Good.
Now, I need to be *absolutely* sure about scenarios where URBs are active at `fail:`. What if we submitted `snd_urb` and then jumped to `fail:`? I had initially thought about this, let's trace it. First, I have to ensure that `snd_urb` is *never* left active when we jump to `fail:`. Let's follow that code...
```c
ret = usb_submit_urb(instance->snd_urb, GFP_KERNEL);
if (ret < 0) {
// snd_urb not active
goto fail;
}
ret = cxacru_start_wait_urb(instance->snd_urb, &instance->snd_done, NULL);
if (ret < 0) {
// snd_urb has completed (either successfully or with error, or timed out and killed)
goto fail;
}
```
If `usb_submit_urb` returns an error, we jump to `fail:` but `snd_urb` is not active, that's fine. The interesting case is when `cxacru_start_wait_urb` times out or errors. `cxacru_start_wait_urb` *itself* calls `usb_unlink_urb` and waits for completion if there is a timeout. So, when `cxacru_start_wait_urb` returns, `snd_urb` *must* be completed, regardless of success, error, or timeout. Therefore, `snd_urb` is never active at `fail:`.
What about signal interrupts? Does a signal mess things up? `wait_for_completion` is the crucial part of `cxacru_start_wait_urb` and it is *not* interruptible. It uses `wait_for_completion` which ignores signals. Thus, it will either succeed in waiting or time out and complete, guaranteeing `snd_urb` is completed before `cxacru_start_wait_urb` returns. So, it's always completed.
Now, let's look at `rcv_urb`.
```c
ret = usb_submit_urb(instance->rcv_urb, GFP_KERNEL);
if (ret < 0) {
// rcv_urb not active
goto fail;
}
```
If `snd_urb` fails to submit *or* the wait for it fails, `rcv_urb` is still active! So, *here* we do need to kill `rcv_urb`.
What if the wait on `rcv_urb` fails?
```c
ret = cxacru_start_wait_urb(instance->rcv_urb, &instance->rcv_done, &actlen);
if (ret < 0) {
// rcv_urb has completed
goto fail;
}
```
If the wait *fails* for `rcv_urb`, it *has* completed, so it is no longer active. So, calling `usb_kill_urb(instance->rcv_urb)` is *still* safe.
What about `snd_urb` wait succeeding, and then `rcv_urb` wait failing? In that case, the `rcv_urb` is also complete. Killing it is safe.
Is there any scenario where `snd_urb` *is* active at `fail:`? No, I'm confident that's covered.
Okay, let's look at a scenario that I think about. What if `usb_submit_urb(instance->snd_urb, GFP_KERNEL)` fails? Then `snd_urb` is not active. But, *`rcv_urb`* is active! So we jump to `fail:`, and `usb_kill_urb(instance->rcv_urb)` will kill it.
Are
|
| 188/4 |
2026/07/31 07:32 |
tool |
codeeditor |
0m
Args: map[CurrentCode: ret = offd;
usb_dbg(instance->usbatm, "cm %#x\n", cm);
fail:
mutex_unlock(&instance->cm_serialize);
err:
return ret;
} NewCode: ret = offd;
usb_dbg(instance->usbatm, "cm %#x\n", cm);
fail:
if (ret < 0)
usb_kill_urb(instance->rcv_urb);
mutex_unlock(&instance->cm_serialize);
err:
return ret;
} SourceFile:drivers/usb/atm/cxacru.c]
Results:
|
| 189/4 |
2026/07/31 07:32 |
llm |
patch-generator |
0m
Model:
Tokens:
input: 23413
output: 26
thoughts: 8
Thoughts: Okay, let's dive into this. Here's my thought process as I approach the provided text, rendered in the first person, assuming I'm already well-versed in the subject matter:
**Initial Assessment: Patch Diff Examination**
Alright, the first thing on the agenda is the patch diff. I need to get a clear understanding of what changes have been proposed or implemented. This is standard operating procedure. I'm already anticipating the common areas of focus β functionality additions, bug fixes, performance optimizations, and potentially, refactoring. My initial scan will be to get a handle on the *scope* of the changes. Are we talking about a minor tweak or something with significant implications? Knowing this will inform how deep I need to go.
|
| 190/4 |
2026/07/31 07:32 |
tool |
patch-diff |
0m
Args: map[File:drivers/usb/atm/cxacru.c]
Results: map[Output:diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
index f1900c567..429ac20a8 100644
--- a/drivers/usb/atm/cxacru.c
+++ b/drivers/usb/atm/cxacru.c
@@ -608,105 +608,107 @@ static int cxacru_start_wait_urb(struct urb *urb, struct completion *done,
static int cxacru_cm(struct cxacru_data *instance, enum cxacru_cm_request cm,
u8 *wdata, int wsize, u8 *rdata, int rsize)
{
int ret, actlen;
int offb, offd;
const int stride = CMD_PACKET_SIZE - 4;
u8 *wbuf = instance->snd_buf;
u8 *rbuf = instance->rcv_buf;
int wbuflen = ((wsize - 1) / stride + 1) * CMD_PACKET_SIZE;
int rbuflen = ((rsize - 1) / stride + 1) * CMD_PACKET_SIZE;
if (wbuflen > PAGE_SIZE || rbuflen > PAGE_SIZE) {
if (printk_ratelimit())
usb_err(instance->usbatm, "requested transfer size too large (%d, %d)\n",
wbuflen, rbuflen);
ret = -ENOMEM;
goto err;
}
mutex_lock(&instance->cm_serialize);
/* submit reading urb before the writing one */
init_completion(&instance->rcv_done);
ret = usb_submit_urb(instance->rcv_urb, GFP_KERNEL);
if (ret < 0) {
if (printk_ratelimit())
usb_err(instance->usbatm, "submit of read urb for cm %#x failed (%d)\n",
cm, ret);
goto fail;
}
memset(wbuf, 0, wbuflen);
/* handle wsize == 0 */
wbuf[0] = cm;
for (offb = offd = 0; offd < wsize; offd += stride, offb += CMD_PACKET_SIZE) {
wbuf[offb] = cm;
memcpy(wbuf + offb + 4, wdata + offd, min_t(int, stride, wsize - offd));
}
instance->snd_urb->transfer_buffer_length = wbuflen;
init_completion(&instance->snd_done);
ret = usb_submit_urb(instance->snd_urb, GFP_KERNEL);
if (ret < 0) {
if (printk_ratelimit())
usb_err(instance->usbatm, "submit of write urb for cm %#x failed (%d)\n",
cm, ret);
goto fail;
}
ret = cxacru_start_wait_urb(instance->snd_urb, &instance->snd_done, NULL);
if (ret < 0) {
if (printk_ratelimit())
usb_err(instance->usbatm, "send of cm %#x failed (%d)\n", cm, ret);
goto fail;
}
ret = cxacru_start_wait_urb(instance->rcv_urb, &instance->rcv_done, &actlen);
if (ret < 0) {
if (printk_ratelimit())
usb_err(instance->usbatm, "receive of cm %#x failed (%d)\n", cm, ret);
goto fail;
}
if (actlen % CMD_PACKET_SIZE || !actlen) {
if (printk_ratelimit())
usb_err(instance->usbatm, "invalid response length to cm %#x: %d\n",
cm, actlen);
ret = -EIO;
goto fail;
}
/* check the return status and copy the data to the output buffer, if needed */
for (offb = offd = 0; offd < rsize && offb < actlen; offb += CMD_PACKET_SIZE) {
if (rbuf[offb] != cm) {
if (printk_ratelimit())
usb_err(instance->usbatm, "wrong cm %#x in response to cm %#x\n",
rbuf[offb], cm);
ret = -EIO;
goto fail;
}
if (rbuf[offb + 1] != CM_STATUS_SUCCESS) {
if (printk_ratelimit())
usb_err(instance->usbatm, "response to cm %#x failed: %#x\n",
cm, rbuf[offb + 1]);
ret = -EIO;
goto fail;
}
if (offd >= rsize)
break;
memcpy(rdata + offd, rbuf + offb + 4, min_t(int, stride, rsize - offd));
offd += stride;
}
ret = offd;
usb_dbg(instance->usbatm, "cm %#x\n", cm);
fail:
+ if (ret < 0)
+ usb_kill_urb(instance->rcv_urb);
mutex_unlock(&instance->cm_serialize);
err:
return ret;
}
static int cxacru_cm_get_array(struct cxacru_data *instance, enum cxacru_cm_request cm,
u32 *data, int size)
{
int ret, len;
__le32 *buf;
]
|
| 191/4 |
2026/07/31 07:32 |
llm |
patch-generator |
0m
Model:
Tokens:
input: 25119
output: 23
thoughts: 1115
Thoughts: **Analyzing URB State and Safety**
Okay, let me break this down. My initial question was whether there were any situations where `snd_urb` or `rcv_urb` were submitted and *not* explicitly waited for. I quickly determined that `cxacru_cm` is the only place where these URBs are submitted.
Now, I started thinking about potential failure scenarios. What if `cxacru_start_wait_urb` fails *after* `snd_urb` is submitted? I went through the code of that function. I saw that `wait_for_completion(done)` will block until the URB completes, either successfully, with an error, or is unlinked by the timer. The timer mechanism (`cxacru_timeout_kill`) uses `usb_unlink_urb`, which, even though asynchronous, will trigger the URB completion handler and signal the completion. So, the `wait_for_completion` *always* returns when the URB is done. That means, `snd_urb` is *guaranteed* to be complete when `cxacru_start_wait_urb` returns.
Then, I considered the case of `usb_submit_urb` failing for `snd_urb`. In that scenario, `snd_urb` is not active, but `rcv_urb` might be. That would lead to the `fail:` path, where `usb_kill_urb(instance->rcv_urb)` is called. I need to make sure this is safe.
Next, I wondered if `usb_submit_urb` could fail for `rcv_urb`. In this case, `rcv_urb` isn't active. Again, we go to `fail:` and call `usb_kill_urb`. But is it safe to kill an URB that wasn't submitted? Yes, based on my understanding, `usb_kill_urb` handles this.
I then considered what if `snd_urb` submitted, `cxacru_start_wait_urb` returned an error. `snd_urb` *is* completed, but `rcv_urb` is still active, so we go to the `fail:` path and kill it.
Also, what if `rcv_urb` submitted, and `snd_urb` submitted, the `snd_urb` wait succeeds, but the `rcv_urb` wait fails? Again, `rcv_urb` is completed. So we hit `fail:` and kill `rcv_urb`. Can we call `usb_kill_urb` on a completed URB? Yes, it's safe.
If `rcv_urb` wait succeeds but the data is invalid, then `rcv_urb` has completed, and we hit `fail:`, where we kill `rcv_urb`. Again, it's safe.
Therefore, this confirms that the proposed fix is completely safe and correct.
Finally, I did a quick sanity check to make sure these URBs aren't used anywhere else: `cxacru_bind` allocates, `cxacru_unbind` frees, and `cxacru_cm` uses them. That's it. I also should check the rest of the drivers in `drivers/usb/atm/` to see if they might have a similar problem.
|
| 192/4 |
2026/07/31 07:32 |
tool |
codesearch-dir-index |
0m
Args:
Results: map[Files:[cxacru.c speedtch.c ueagle-atm.c usbatm.c usbatm.h xusbatm.c] Subdirs:<nil>]
|
| 193/4 |
2026/07/31 07:32 |
llm |
patch-generator |
0m
Model:
Tokens:
input: 27028
output: 35
thoughts: 10
Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience:
**Analyzing `speedtch.c`**
Alright, time to dive into `speedtch.c`. This is where the core timing and potentially the performance bottlenecks reside. I need to quickly assess the structure β what's the general architecture? Is it event-driven, threaded, or a more straightforward sequential approach? My gut feeling is we're likely dealing with something relatively performance-sensitive, given the filename, so I'll be looking closely at any potential locking contention, memory allocation patterns, and the efficiency of the core timing loops. I need to see how the timestamps are captured β are we relying on `gettimeofday`, `clock_gettime`, or something even lower-level like RDTSC? The choice there will tell me a lot about the potential resolution and overhead. The goal is to identify any areas where a more modern or optimized approach could yield a significant improvement. I'll be mentally parsing the code for hints of potential optimization, whether it's through vectorized operations, improved data structures, or even just clever compiler hints. Let's see what we've got.
|
| 194/4 |
2026/07/31 07:32 |
tool |
grepper |
0m
Args: map[Expression:usb_submit_urb PathPrefix:drivers/usb/atm/speedtch.c]
Results: map[Output:drivers/usb/atm/speedtch.c=576=static void speedtch_resubmit_int(struct timer_list *t)
--
drivers/usb/atm/speedtch.c-586- if (int_urb) {
drivers/usb/atm/speedtch.c:587: ret = usb_submit_urb(int_urb, GFP_ATOMIC);
drivers/usb/atm/speedtch.c-588- if (!ret)
--
drivers/usb/atm/speedtch.c-590- else {
drivers/usb/atm/speedtch.c:591: atm_dbg(instance->usbatm, "%s: usb_submit_urb failed with result %d\n", __func__, ret);
drivers/usb/atm/speedtch.c-592- mod_timer(&instance->resubmit_timer, jiffies + msecs_to_jiffies(RESUBMIT_DELAY));
--
drivers/usb/atm/speedtch.c=597=static void speedtch_handle_int(struct urb *int_urb)
--
drivers/usb/atm/speedtch.c-633- if (int_urb) {
drivers/usb/atm/speedtch.c:634: ret = usb_submit_urb(int_urb, GFP_ATOMIC);
drivers/usb/atm/speedtch.c-635- schedule_work(&instance->status_check_work);
drivers/usb/atm/speedtch.c-636- if (ret < 0) {
drivers/usb/atm/speedtch.c:637: atm_dbg(usbatm, "%s: usb_submit_urb failed with result %d\n", __func__, ret);
drivers/usb/atm/speedtch.c-638- goto fail;
--
drivers/usb/atm/speedtch.c=650=static int speedtch_atm_start(struct usbatm_data *usbatm, struct atm_dev *atm_dev)
--
drivers/usb/atm/speedtch.c-671- if (instance->int_urb) {
drivers/usb/atm/speedtch.c:672: ret = usb_submit_urb(instance->int_urb, GFP_KERNEL);
drivers/usb/atm/speedtch.c-673- if (ret < 0) {
]
|
| 195/4 |
2026/07/31 07:32 |
llm |
patch-generator |
0m
Model:
Tokens:
input: 27908
output: 40
thoughts: 81
Thoughts: **Analyzing the USB ATM Initialization**
Okay, so `speedtch.c` is submitting an `int_urb`. My immediate concern is what happens if `usb_submit_urb` fails within `speedtch_atm_start`. It looks like it just returns the error, which is good. But... `speedtch_atm_start` is called by `usbatm_atm_init`. This makes me wonder: does it handle all the URBs it creates, or could it potentially leave one active if an error occurs during initialization? I need to verify. Let's dig back into the `speedtch_atm_start` function and make sure that it cleans up properly in all error paths. I have to be absolutely certain there are no lingering URBs hanging around after an unsuccessful start.
|
| 196/4 |
2026/07/31 07:32 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/usb/atm/speedtch.c Name:speedtch_atm_start]
Results: map[SourceCode: 650: static int speedtch_atm_start(struct usbatm_data *usbatm, struct atm_dev *atm_dev)
651: {
652: struct usb_device *usb_dev = usbatm->usb_dev;
653: struct speedtch_instance_data *instance = usbatm->driver_data;
654: int i, ret;
655: unsigned char mac_str[13];
656:
657: atm_dbg(usbatm, "%s entered\n", __func__);
658:
659: /* Set MAC address, it is stored in the serial number */
660: memset(atm_dev->esi, 0, sizeof(atm_dev->esi));
661: if (usb_string(usb_dev, usb_dev->descriptor.iSerialNumber, mac_str, sizeof(mac_str)) == 12) {
662: for (i = 0; i < 6; i++)
663: atm_dev->esi[i] = (hex_to_bin(mac_str[i * 2]) << 4) +
664: hex_to_bin(mac_str[i * 2 + 1]);
665: }
666:
667: /* Start modem synchronisation */
668: ret = speedtch_start_synchro(instance);
669:
670: /* Set up interrupt endpoint */
671: if (instance->int_urb) {
672: ret = usb_submit_urb(instance->int_urb, GFP_KERNEL);
673: if (ret < 0) {
674: /* Doesn't matter; we'll poll anyway */
675: atm_dbg(usbatm, "%s: submission of interrupt URB failed (%d)!\n", __func__, ret);
676: usb_free_urb(instance->int_urb);
677: instance->int_urb = NULL;
678: }
679: }
680:
681: /* Start status polling */
682: mod_timer(&instance->status_check_timer, jiffies + msecs_to_jiffies(1000));
683:
684: return 0;
685: }
SourceFile:drivers/usb/atm/speedtch.c]
|
| 197/4 |
2026/07/31 07:32 |
llm |
patch-generator |
0m
Model:
Tokens:
input: 28868
output: 37
thoughts: 41
Thoughts: Okay, here's my interpretation of those thoughts, presented as a personal thought process, as requested:
**URB Handling and the `ueagle-atm` Module**
Alright, so if `usb_submit_urb` fails, that's pretty standard practice: the function will clean up after itself by freeing the URB and setting the pointer to `NULL`. Good; it's what I expect. I'm not worried about left-over active URBs causing issues. The system isn't going to get jammed up. It keeps things tidy.
However, the question that *immediately* pops into my head now is: How does this work within `ueagle-atm.c`? That's the critical bit. I need to make sure this module's error handling is robust. I need to know: Is it correctly checking for `usb_submit_urb` failures? If the submission *does* fail, is the URB pointer being checked for `NULL` before any further operations? Are we handling the situation gracefully, without potential memory leaks or trying to access freed memory? I need to dig into the `ueagle-atm.c` code to see if this best-practice is followed, or if there's a vulnerability.
|
| 198/4 |
2026/07/31 07:32 |
tool |
grepper |
0m
Args: map[Expression:usb_submit_urb PathPrefix:drivers/usb/atm/ueagle-atm.c]
Results: map[Output:drivers/usb/atm/ueagle-atm.c=2057=static void uea_intr(struct urb *urb)
--
drivers/usb/atm/ueagle-atm.c-2089-resubmit:
drivers/usb/atm/ueagle-atm.c:2090: usb_submit_urb(sc->urb_int, GFP_ATOMIC);
drivers/usb/atm/ueagle-atm.c-2091-}
--
drivers/usb/atm/ueagle-atm.c=2096=static int uea_boot(struct uea_softc *sc, struct usb_interface *intf)
--
drivers/usb/atm/ueagle-atm.c-2140-
drivers/usb/atm/ueagle-atm.c:2141: ret = usb_submit_urb(sc->urb_int, GFP_KERNEL);
drivers/usb/atm/ueagle-atm.c-2142- if (ret < 0) {
]
|
| 199/4 |
2026/07/31 07:32 |
llm |
patch-generator |
0m
Model:
Tokens:
input: 29464
output: 40
thoughts: 10
Thoughts: Okay, here's my attempt at summarizing my internal thought process as an expert, as requested:
**Assessing the `uea_boot` Module**
Alright, time to dive into this. Let's start with `uea_boot`. That's the entry point, the critical first step. I need to quickly assess what it's doing, its dependencies, and what kind of potential problems or optimizations I should be looking for. Is it a standard bootloader, or something custom? Are there any obvious areas for vulnerability? What's the hardware context? Knowing this will influence the analysis. Gotta keep in mind the bigger picture: what system is this actually booting? Is it a bare-metal environment, or something running on a hypervisor? The answers to those questions will shape how I approach this. Let's get to it.
|
| 200/4 |
2026/07/31 07:33 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/usb/atm/ueagle-atm.c Name:uea_boot]
Results: map[SourceCode:2093: /*
2094: * Start the modem : init the data and start kernel thread
2095: */
2096: static int uea_boot(struct uea_softc *sc, struct usb_interface *intf)
2097: {
2098: struct intr_pkt *intr;
2099: int ret = -ENOMEM;
2100: int size;
2101:
2102: if (UEA_CHIP_VERSION(sc) == EAGLE_IV) {
2103: size = E4_INTR_PKT_SIZE;
2104: sc->dispatch_cmv = uea_dispatch_cmv_e4;
2105: sc->schedule_load_page = uea_schedule_load_page_e4;
2106: sc->stat = uea_stat_e4;
2107: sc->send_cmvs = uea_send_cmvs_e4;
2108: INIT_WORK(&sc->task, uea_load_page_e4);
2109: } else {
2110: size = E1_INTR_PKT_SIZE;
2111: sc->dispatch_cmv = uea_dispatch_cmv_e1;
2112: sc->schedule_load_page = uea_schedule_load_page_e1;
2113: sc->stat = uea_stat_e1;
2114: sc->send_cmvs = uea_send_cmvs_e1;
2115: INIT_WORK(&sc->task, uea_load_page_e1);
2116: }
2117:
2118: init_waitqueue_head(&sc->sync_q);
2119:
2120: if (UEA_CHIP_VERSION(sc) == ADI930)
2121: load_XILINX_firmware(sc);
2122:
2123: if (intf->cur_altsetting->desc.bNumEndpoints < 1) {
2124: ret = -ENODEV;
2125: goto err0;
2126: }
2127:
2128: intr = kmalloc(size, GFP_KERNEL);
2129: if (!intr)
2130: goto err0;
2131:
2132: sc->urb_int = usb_alloc_urb(0, GFP_KERNEL);
2133: if (!sc->urb_int)
2134: goto err1;
2135:
2136: usb_fill_int_urb(sc->urb_int, sc->usb_dev,
2137: usb_rcvintpipe(sc->usb_dev, UEA_INTR_PIPE),
2138: intr, size, uea_intr, sc,
2139: intf->cur_altsetting->endpoint[0].desc.bInterval);
2140:
2141: ret = usb_submit_urb(sc->urb_int, GFP_KERNEL);
2142: if (ret < 0) {
2143: uea_err(INS_TO_USBDEV(sc),
2144: "urb submission failed with error %d\n", ret);
2145: goto err1;
2146: }
2147:
2148: /* Create worker thread, but don't start it here. Start it after
2149: * all usbatm generic initialization is done.
2150: */
2151: sc->kthread = kthread_create(uea_kthread, sc, "ueagle-atm");
2152: if (IS_ERR(sc->kthread)) {
2153: uea_err(INS_TO_USBDEV(sc), "failed to create thread\n");
2154: ret = PTR_ERR(sc->kthread);
2155: goto err2;
2156: }
2157:
2158: return 0;
2159:
2160: err2:
2161: usb_kill_urb(sc->urb_int);
2162: err1:
2163: usb_free_urb(sc->urb_int);
2164: sc->urb_int = NULL;
2165: kfree(intr);
2166: err0:
2167: return ret;
2168: }
SourceFile:drivers/usb/atm/ueagle-atm.c]
|
| 201/4 |
2026/07/31 07:33 |
llm |
patch-generator |
0m
Model:
Tokens:
input: 30945
output: 44
thoughts: 895
Thoughts: **Analyzing the cxacru URB Handling**
Okay, so I'm digging into this `uea_boot` issue, and it looks like the problem, specifically within `cxacru.c`, is that we're not properly handling URB cancellation on error paths. I recall that `kthread_create` failure is properly handled by calling `usb_kill_urb`, so it's a `cxacru.c` specific issue.
Let's re-examine this proposed fix: it unconditionally calls `usb_kill_urb(instance->rcv_urb)` when there's an error in `cxacru_cm`. Right, that's what was suggested, and it makes sense. I need to make sure this is complete and correct.
The primary concern is ensuring all URBs are correctly killed under all scenarios. Is there another URB we're missing? Nope, looks like only `rcv_urb`, or are there other submission points for the `rcv_urb`? Nope. What about `snd_urb`? No, or any other submission points? No. Hmm, does `snd_urb` ever get *stuck* as active when we hit that `fail:` label? No, because `cxacru_start_wait_urb` explicitly waits for its completion.
But wait, what if `cxacru_start_wait_urb` gets interrupted during its wait? It uses `wait_for_completion`, and that's *not* interruptible. So, it'll block until the URB finishes or times out. In the timeout case, `cxacru_timeout_kill` gets called, which unlinks the URB. That unlink is asynchronous, but it *will* generate a completion with an error like `-ECONNRESET`, which will execute the completion handler and signal `done`. Therefore `wait_for_completion(done)` will return, and when `cxacru_start_wait_urb` returns, the `snd_urb` is *guaranteed* to be done, one way or another. So `snd_urb` won't be active.
Okay, what about calling `usb_kill_urb` on `rcv_urb` when it's *already* completed? Or what if it was never submitted in the first place? *Phew*, `usb_kill_urb` is safe to call in either case. That's a huge relief.
Alright, after this careful analysis, this fix is perfectly safe and correct.
The fundamental issue is that `cxacru_cm()` can leave the `rcv_urb` active if there's an error submitting or waiting for the `snd_urb`. The calling function, `cxacru_atm_start()`, is then happily polling and calling `cxacru_cm()` again, and we get the warning when trying to resubmit an already active URB.
The fix is the unconditional `usb_kill_urb(instance->rcv_urb)` call in that error path. This forces the URB to stop. `usb_kill_urb()`'s robustness handles the cases where the URB might have not been submitted or already completed. As for `snd_urb`, it's not active because `cxacru_start_wait_urb()` waits for completion.
I'm confident in the correctness of this. I applied the fix using the `codeeditor` tool, and I verified the changes with the `patch-diff` tool, and it follows kernel best practices.
|
| 202/4 |
2026/07/31 07:33 |
tool |
codeexpert |
0m
Args: map[Question:Is wait_for_completion() interruptible? If a thread is waiting in wait_for_completion(), can it be interrupted by a signal?]
Results: map[Answer:No, `wait_for_completion()` is **not** interruptible.
If a thread is waiting in `wait_for_completion()`, it **cannot** be interrupted by a signal.
### Technical Details:
1. **Task State**: Under the hood, `wait_for_completion()` calls `wait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_UNINTERRUPTIBLE)`. Because it sets the task's state to `TASK_UNINTERRUPTIBLE`, the waiting thread ignores standard signals and will not wake up or return until the completion is signaled via `complete()` or `complete_all()`.
2. **Alternatives**:
- If you need a wait that can be interrupted by any signal, you should use **`wait_for_completion_interruptible()`** (which sets the task state to `TASK_INTERRUPTIBLE` and returns `-ERESTARTSYS` if interrupted).
- If you need a wait that can only be interrupted by fatal/kill signals, you should use **`wait_for_completion_killable()`** (which sets the task state to `TASK_KILLABLE` and returns `-ERESTARTSYS` if interrupted by a fatal signal).]
|
| 203/5 |
2026/07/31 07:33 |
agent |
codeexpert |
0m
Model:
Results: map[Answer:No, `wait_for_completion()` is **not** interruptible.
If a thread is waiting in `wait_for_completion()`, it **cannot** be interrupted by a signal.
### Technical Details:
1. **Task State**: Under the hood, `wait_for_completion()` calls `wait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_UNINTERRUPTIBLE)`. Because it sets the task's state to `TASK_UNINTERRUPTIBLE`, the waiting thread ignores standard signals and will not wake up or return until the completion is signaled via `complete()` or `complete_all()`.
2. **Alternatives**:
- If you need a wait that can be interrupted by any signal, you should use **`wait_for_completion_interruptible()`** (which sets the task state to `TASK_INTERRUPTIBLE` and returns `-ERESTARTSYS` if interrupted).
- If you need a wait that can only be interrupted by fatal/kill signals, you should use **`wait_for_completion_killable()`** (which sets the task state to `TASK_KILLABLE` and returns `-ERESTARTSYS` if interrupted by a fatal signal).]
Instruction:
You are a capable Linux kernel developer tasked with researching complex questions
about kernel source code. You will be given a concrete question, and need to provide
a concrete answer.
Use tools extensively while researching the question. Don't make assumptions,
or rely on your previous knowledge about the kernel source code, use available tools
to access the actual source code.
Use all available sources of information:
- kernel source code
- documentation in the Documentation dir in the source tree
- git commits descriptions, git blame
Do not guess file names or file paths and attempt to read them without
verifying their existence first using content search or directory listing tools.
If a file, symbol, or directory is not found via content search (grepper) or
directory listing (codesearch-dir-index), treat it as completely absent.
Do not attempt to guess alternative names, extensions, or directories.
Tool Selection Guidelines:
1. For C functions, structs, and variables: Prefer codesearch-definition-source
or codesearch-struct-layout FIRST to retrieve clean, exact definitions
without line-number guessing.
2. If symbol lookup fails (e.g., preprocessor macros, macro-generated code, or
disabled #ifdef branches), fall back to read-file or grepper.
3. For file headers, #include directives, preprocessor macro definitions, and
non-C files (Kconfig, Makefiles, docs): Use read-file or grepper directly.
Do NOT use git-log to search for the presence or existence of files in the
repository. git-log is only for tracing commit history of files that are
already present in the current checkout. If a file does not exist in the
current checkout, it cannot be used for reproduction.
Avoid running broad git-log queries (such as searches on the entire repo)
without a specific 'PathPrefix' to restrict the scope, as these are very
expensive and will time out.
If a git-log tool call times out, do not retry the query with the same broad
scope. You must specify a tighter, narrower 'PathPrefix' for subsequent queries.
Prefer calling several tools at the same time to save round-trips.
Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.
Prompt: Is wait_for_completion() interruptible? If a thread is waiting in wait_for_completion(), can it be interrupted by a signal?
|
| 204/6 |
2026/07/31 07:33 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 3891
output: 36
thoughts: 94
Thoughts: **Investigating Interruptibility of `wait_for_completion()`**
Okay, so the question is straightforward: Can a call to `wait_for_completion()` be interrupted? More specifically, if a thread is blocked inside `wait_for_completion()`, can a signal yank it out? I need to understand the interruptibility behavior of this function.
To get the definitive answer, I'm going to head straight to the source. Let's see... I'll use `codesearch-definition-source` or `codesearch-definition-comment` for `wait_for_completion` to pinpoint the definition within the kernel code. That's the only way to be absolutely sure about its signal handling and any potential interrupt mechanisms it might employ. Understanding the exact implementation details is critical for answering this question definitively.
|
| 205/6 |
2026/07/31 07:33 |
tool |
codesearch-definition-comment |
0m
Args: map[ContextFile:kernel/sched/completion.c Name:wait_for_completion]
Results: map[Comment: 141: /**
142: * wait_for_completion: - waits for completion of a task
143: * @x: holds the state of this particular completion
144: *
145: * This waits to be signaled for completion of a specific task. It is NOT
146: * interruptible and there is no timeout.
147: *
148: * See also similar routines (i.e. wait_for_completion_timeout()) with timeout
149: * and interrupt capability. Also see complete().
150: */
Kind:function]
|
| 206/6 |
2026/07/31 07:33 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 4368
output: 36
thoughts: 20
Thoughts: Okay, let's dive into this. Here's my thought process on this:
**Deep Dive into `wait_for_completion` Implementation**
Right, so we need to be absolutely certain about how `wait_for_completion` actually works under the hood. I know the general idea, the API surface, but I need to scrutinize the implementation details, the nitty-gritty code itself. This isn't just a casual review; this is about solidifying my understanding and perhaps identifying subtle edge cases or performance bottlenecks that might not be immediately obvious from just reading the documentation or using the function in a simple scenario. I'm going to look for thread synchronization primitives, any potential for deadlocks or race conditions, and how it handles different failure modes β what happens if the operation times out, or if there's an unexpected exception thrown during the process it's waiting on. I also need to verify that it's using the correct system calls or library functions for optimal performance in various situations. It's time to get a more granular, line-by-line understanding, just to be sure.
|
| 207/6 |
2026/07/31 07:33 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:kernel/sched/completion.c Name:wait_for_completion]
Results: map[SourceCode: 141: /**
142: * wait_for_completion: - waits for completion of a task
143: * @x: holds the state of this particular completion
144: *
145: * This waits to be signaled for completion of a specific task. It is NOT
146: * interruptible and there is no timeout.
147: *
148: * See also similar routines (i.e. wait_for_completion_timeout()) with timeout
149: * and interrupt capability. Also see complete().
150: */
151: void __sched wait_for_completion(struct completion *x)
152: {
153: wait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_UNINTERRUPTIBLE);
154: }
SourceFile:kernel/sched/completion.c]
|
| 208/6 |
2026/07/31 07:33 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 4906
output: 26
thoughts: 152
Thoughts: **Analyzing the Implication of an Uninterruptible Wait**
Okay, so I'm looking at this code snippet, and the comment is pretty clear: this `wait_for_completion` function is *not* going to be interrupted. It patiently waits for a signal and has no timeout. The implementation confirms this, using `TASK_UNINTERRUPTIBLE`. That's the key. This line means the task will block until it gets the signal, and won't respond to any signals in the meantime, which makes sense for the intended behavior.
However, I'm an expert in this area, so I want to be comprehensive. While this specific function's behavior is clear, let's explore this further. Just to confirm that this is the only option, I'll quickly check the other related wait functions. I will examine `kernel/sched/completion.c` to see if there are *other* completion wait functions and, if so, whether any of them offer an interruptible option. That will allow me to be certain in my analysis. I would want to have a definitive answer for my audience.
|
| 209/6 |
2026/07/31 07:33 |
tool |
codesearch-file-index |
0m
Args: map[SourceFile:kernel/sched/completion.c]
Results: map[Entities:[map[Kind:function Name:__wait_for_common] map[Kind:function Name:complete] map[Kind:function Name:complete_all] map[Kind:function Name:complete_on_current_cpu] map[Kind:function Name:complete_with_flags] map[Kind:function Name:completion_done] map[Kind:function Name:do_wait_for_common] map[Kind:function Name:try_wait_for_completion] map[Kind:function Name:wait_for_common] map[Kind:function Name:wait_for_common_io] map[Kind:function Name:wait_for_completion] map[Kind:function Name:wait_for_completion_interruptible] map[Kind:function Name:wait_for_completion_interruptible_timeout] map[Kind:function Name:wait_for_completion_io] map[Kind:function Name:wait_for_completion_io_timeout] map[Kind:function Name:wait_for_completion_killable] map[Kind:function Name:wait_for_completion_killable_timeout] map[Kind:function Name:wait_for_completion_state] map[Kind:function Name:wait_for_completion_timeout] map[Kind:global_variable Name:__UNIQUE_ID_addressable_complete_1743] map[Kind:global_variable Name:__UNIQUE_ID_addressable_complete_all_1745] map[Kind:global_variable Name:__UNIQUE_ID_addressable_completion_done_1761] map[Kind:global_variable Name:__UNIQUE_ID_addressable_try_wait_for_completion_1759] map[Kind:global_variable Name:__UNIQUE_ID_addressable_wait_for_completion_1749] map[Kind:global_variable Name:__UNIQUE_ID_addressable_wait_for_completion_interruptible_1753] map[Kind:global_variable Name:__UNIQUE_ID_addressable_wait_for_completion_interruptible_timeout_1754] map[Kind:global_variable Name:__UNIQUE_ID_addressable_wait_for_completion_io_1751] map[Kind:global_variable Name:__UNIQUE_ID_addressable_wait_for_completion_io_timeout_1752] map[Kind:global_variable Name:__UNIQUE_ID_addressable_wait_for_completion_killable_1755] map[Kind:global_variable Name:__UNIQUE_ID_addressable_wait_for_completion_killable_timeout_1757] map[Kind:global_variable Name:__UNIQUE_ID_addressable_wait_for_completion_state_1756] map[Kind:global_variable Name:__UNIQUE_ID_addressable_wait_for_completion_timeout_1750] map[Kind:global_variable Name:__gendwarfksyms_ptr_complete] map[Kind:global_variable Name:__gendwarfksyms_ptr_complete_all] map[Kind:global_variable Name:__gendwarfksyms_ptr_completion_done] map[Kind:global_variable Name:__gendwarfksyms_ptr_try_wait_for_completion] map[Kind:global_variable Name:__gendwarfksyms_ptr_wait_for_completion] map[Kind:global_variable Name:__gendwarfksyms_ptr_wait_for_completion_interruptible] map[Kind:global_variable Name:__gendwarfksyms_ptr_wait_for_completion_interruptible_timeout] map[Kind:global_variable Name:__gendwarfksyms_ptr_wait_for_completion_io] map[Kind:global_variable Name:__gendwarfksyms_ptr_wait_for_completion_io_timeout] map[Kind:global_variable Name:__gendwarfksyms_ptr_wait_for_completion_killable] map[Kind:global_variable Name:__gendwarfksyms_ptr_wait_for_completion_killable_timeout] map[Kind:global_variable Name:__gendwarfksyms_ptr_wait_for_completion_state] map[Kind:global_variable Name:__gendwarfksyms_ptr_wait_for_completion_timeout]]]
|
| 210/6 |
2026/07/31 07:33 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 6457
output: 39
thoughts: 18
Thoughts: Here's my analysis of the provided snippet, framed as my own thought process:
**Diving Deeper: Exploring `wait_for_completion_interruptible`**
Okay, I'm already pretty familiar with the general workflow, but it's important to be thorough. I need to understand this whole process fully. I've been focusing on the core, but now I think I should switch my attention to `wait_for_completion_interruptible`. It's a key function in handling concurrency and potentially blocking operations, so understanding how it interacts with the rest of the system is critical to a comprehensive understanding of the implementation. I'm going to dig into its code and usage patterns next. Let's see what interesting insights I can uncover there. It's a key part of the puzzle.
|
| 211/6 |
2026/07/31 07:33 |
tool |
codesearch-definition-comment |
0m
Args: map[ContextFile:kernel/sched/completion.c Name:wait_for_completion_interruptible]
Results: map[Comment: 210: /**
211: * wait_for_completion_interruptible: - waits for completion of a task (w/intr)
212: * @x: holds the state of this particular completion
213: *
214: * This waits for completion of a specific task to be signaled. It is
215: * interruptible.
216: *
217: * Return: -ERESTARTSYS if interrupted, 0 if completed.
218: */
Kind:function]
|
| 212/6 |
2026/07/31 07:33 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 6841
output: 39
thoughts: 10
Thoughts: Okay, let's dive into this. Here's my perspective on examining the source code:
**Diving Deep into the Code**
Alright, so we're taking a look at the source code now. That's fantastic. This is where the rubber really meets the road. I need to understand not just what the system *does*, but *how* it does it. This is where the magic (or the problems!) lie. I'm going to be looking for architecture, design patterns, any obvious algorithmic inefficiencies, potential security vulnerabilities... the whole nine yards. I'll be expecting clean, well-documented code, hopefully following solid coding principles. The goal is to see if any obvious vulnerabilities are present or ways to optimize performance.
|
| 213/6 |
2026/07/31 07:33 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:kernel/sched/completion.c Name:wait_for_completion_interruptible]
Results: map[SourceCode: 210: /**
211: * wait_for_completion_interruptible: - waits for completion of a task (w/intr)
212: * @x: holds the state of this particular completion
213: *
214: * This waits for completion of a specific task to be signaled. It is
215: * interruptible.
216: *
217: * Return: -ERESTARTSYS if interrupted, 0 if completed.
218: */
219: int __sched wait_for_completion_interruptible(struct completion *x)
220: {
221: long t = wait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_INTERRUPTIBLE);
222:
223: if (t == -ERESTARTSYS)
224: return t;
225: return 0;
226: }
SourceFile:kernel/sched/completion.c]
|
| 214/6 |
2026/07/31 07:33 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 7327
output: 39
thoughts: 11
Thoughts: Okay, here's my interpretation of that.
**Analyzing the `wait_for_completion_killable` Function**
Alright, let's break this down. When I see `wait_for_completion_killable`, my expert mind immediately starts thinking about concurrent processes, thread management, and resource cleanup. This function is obviously designed for a scenario where we have a task or a process running, and we need a robust mechanism to wait for its completion β *but* with the crucial ability to interrupt or terminate it if necessary. This implies a potentially long-running operation that might need to be cancelled, perhaps due to timeouts, user requests, or external events.
My first thought is around thread safety. If this function is part of a multi-threaded application, it needs to handle concurrency carefully. Specifically, is there a risk of race conditions or deadlocks? What synchronization primitives are being used? Mutexes? Semaphores? Condition variables? I'll need to look deeper into the specific implementation to see how it manages shared resources.
Then there's the 'killable' aspect. How is the termination implemented? Is it using signals (like SIGTERM or SIGKILL on Linux/Unix systems), thread-level interrupts, or a more sophisticated approach? A graceful shutdown would be ideal, where the process can clean up its resources before termination, but a forced kill might be necessary in certain scenarios. Understanding the termination strategy is crucial. I need to figure out what happens if the operation doesn't respond to a "graceful" termination request. Does this function have a timeout or any other way to avoid it hanging indefinitely?
Furthermore, I have to consider error handling. What happens if the process completes successfully? How are different exit codes or return values handled? Does the function differentiate between clean completion, an intentional termination, or an unexpected error? And equally important, does it have robust error handling? It should be able to log errors effectively and perhaps raise exceptions if necessary.
Finally, I'm already wondering about resource management. What resources does the waited-for process own? Files? Network connections? Memory? The `wait_for_completion_killable` function has a responsibility to ensure these resources are properly released, regardless of how the waited-for process completes. Memory leaks, dangling file descriptors, and orphaned connections are all nightmares that this function *must* avoid. I will be looking closely at how resources are tracked and cleaned up.
|
| 215/6 |
2026/07/31 07:33 |
tool |
codesearch-definition-comment |
0m
Args: map[ContextFile:kernel/sched/completion.c Name:wait_for_completion_killable]
Results: map[Comment: 248: /**
249: * wait_for_completion_killable: - waits for completion of a task (killable)
250: * @x: holds the state of this particular completion
251: *
252: * This waits to be signaled for completion of a specific task. It can be
253: * interrupted by a kill signal.
254: *
255: * Return: -ERESTARTSYS if interrupted, 0 if completed.
256: */
Kind:function]
|
| 216/6 |
2026/07/31 07:33 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 8045
output: 39
thoughts: 10
Thoughts: Okay, let's dive into this. Here's my perspective on examining the source code:
**Diving Deep into the Code**
Alright, so we're taking a look at the source code now. That's fantastic. This is where the rubber really meets the road. I need to understand not just what the system *does*, but *how* it does it. This is where the magic (or the problems!) lie. I'm going to be looking for architecture, design patterns, any obvious algorithmic inefficiencies, potential security vulnerabilities... the whole nine yards. I'll be expecting clean, well-documented code, hopefully following solid coding principles. The goal is to see if any obvious vulnerabilities are present or ways to optimize performance.
|
| 217/6 |
2026/07/31 07:33 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:kernel/sched/completion.c Name:wait_for_completion_killable]
Results: map[SourceCode: 248: /**
249: * wait_for_completion_killable: - waits for completion of a task (killable)
250: * @x: holds the state of this particular completion
251: *
252: * This waits to be signaled for completion of a specific task. It can be
253: * interrupted by a kill signal.
254: *
255: * Return: -ERESTARTSYS if interrupted, 0 if completed.
256: */
257: int __sched wait_for_completion_killable(struct completion *x)
258: {
259: long t = wait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_KILLABLE);
260:
261: if (t == -ERESTARTSYS)
262: return t;
263: return 0;
264: }
SourceFile:kernel/sched/completion.c]
|
| 218/6 |
2026/07/31 07:33 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 8532
output: 278
thoughts: 201
Thoughts: **My Analysis of Interruptibility in `wait_for_completion()`**
Right, this is clear. We've got everything we need here. Let me just confirm those crucial points from the original questions:
* **Question 1:** Is `wait_for_completion()` interruptible? The answer is definitively no.
* **Question 2:** If a thread is stuck in `wait_for_completion()`, can a signal interrupt it? Again, the answer is no. This is because the function puts the task into the `TASK_UNINTERRUPTIBLE` state, which means signals are ignored. Thatβs the core of the behavior we're seeing.
Now, it's important to add some nuance here for the sake of completeness, and for the benefit of anyone looking at this later on. I need to be clear that the behavior isn't the *only* option. There are alternative functions to be aware of:
* `wait_for_completion_interruptible()` - This utilizes `TASK_INTERRUPTIBLE`. That means the wait can be interrupted by *any* signal, with a return value of `-ERESTARTSYS`.
* `wait_for_completion_killable()` - This is even more specific, using `TASK_KILLABLE`. It's interruptible, but only by fatal or kill signals, still returning `-ERESTARTSYS`.
Okay, I'm confident in the summary now. Time to use the `set-results` tool and get the answer properly documented.
|
| 219/6 |
2026/07/31 07:33 |
tool |
set-results |
0m
Args: map[Answer:No, `wait_for_completion()` is **not** interruptible.
If a thread is waiting in `wait_for_completion()`, it **cannot** be interrupted by a signal.
### Technical Details:
1. **Task State**: Under the hood, `wait_for_completion()` calls `wait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_UNINTERRUPTIBLE)`. Because it sets the task's state to `TASK_UNINTERRUPTIBLE`, the waiting thread ignores standard signals and will not wake up or return until the completion is signaled via `complete()` or `complete_all()`.
2. **Alternatives**:
- If you need a wait that can be interrupted by any signal, you should use **`wait_for_completion_interruptible()`** (which sets the task state to `TASK_INTERRUPTIBLE` and returns `-ERESTARTSYS` if interrupted).
- If you need a wait that can only be interrupted by fatal/kill signals, you should use **`wait_for_completion_killable()`** (which sets the task state to `TASK_KILLABLE` and returns `-ERESTARTSYS` if interrupted by a fatal signal).]
Results: map[Answer:No, `wait_for_completion()` is **not** interruptible.
If a thread is waiting in `wait_for_completion()`, it **cannot** be interrupted by a signal.
### Technical Details:
1. **Task State**: Under the hood, `wait_for_completion()` calls `wait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_UNINTERRUPTIBLE)`. Because it sets the task's state to `TASK_UNINTERRUPTIBLE`, the waiting thread ignores standard signals and will not wake up or return until the completion is signaled via `complete()` or `complete_all()`.
2. **Alternatives**:
- If you need a wait that can be interrupted by any signal, you should use **`wait_for_completion_interruptible()`** (which sets the task state to `TASK_INTERRUPTIBLE` and returns `-ERESTARTSYS` if interrupted).
- If you need a wait that can only be interrupted by fatal/kill signals, you should use **`wait_for_completion_killable()`** (which sets the task state to `TASK_KILLABLE` and returns `-ERESTARTSYS` if interrupted by a fatal signal).]
|
| 220/4 |
2026/07/31 07:33 |
llm |
patch-generator |
0m
Model:
Tokens:
input: 32916
output: 681
thoughts: 76
Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience:
**Finalizing the Fix: Interruptibility & URB Completion**
Right, that's exactly what I wanted to see. The `wait_for_completion` function's non-interruptible nature is the key here. This means `cxacru_start_wait_urb` will *guaranteed* block until either the USB Request Block (URB) is done or we hit the timeout. This is the behavior we *need*.
And that implication... that `snd_urb` won't be active when `cxacru_start_wait_urb` exits? That's golden. It cleanly avoids the race condition we were worried about.
Yep, the solution is rock solid. It addresses the core issue in a manner that's both efficient and avoids any potential side effects. I'm ready to move forward and wrap this up with the final response.
|
| 221/3 |
2026/07/31 07:34 |
action |
test-patch |
18m
Results: map[PatchDiff:diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
index f1900c567..429ac20a8 100644
--- a/drivers/usb/atm/cxacru.c
+++ b/drivers/usb/atm/cxacru.c
@@ -700,6 +700,8 @@ static int cxacru_cm(struct cxacru_data *instance, enum cxacru_cm_request cm,
ret = offd;
usb_dbg(instance->usbatm, "cm %#x\n", cm);
fail:
+ if (ret < 0)
+ usb_kill_urb(instance->rcv_urb);
mutex_unlock(&instance->cm_serialize);
err:
return ret;
TestError:]
|
| 222/1 |
2026/07/31 07:52 |
action |
apply-patch |
0m
Results:
|
| 223/1 |
2026/07/31 07:52 |
action |
init-style-items |
0m
Results:
|
| 224/1 |
2026/07/31 07:52 |
loop |
|
0m
|
| 225/2 |
2026/07/31 07:52 |
iteration |
0 |
0m
|
| 226/3 |
2026/07/31 07:52 |
agent |
patch-formatter |
0m
Model:
Instruction:
You are an expert Linux kernel developer tasked with formatting a kernel patch.
Your objective is purely formatting: you must ensure the patch complies with the kernel's coding style,
conforms to the surrounding code rules, and passes checkpatch.pl, while preserving the code logic exactly as it is.
You should stop once the requested formatting changes are done and checkpatch.pl is happy.
Do not question the requested changes unless they are obviously wrong.
If the code already conforms to the requested changes, surrounding code rules,
and checkpatch.pl is happy, you should just finish your task.
WARNING: The clang-format tool may break the formatting of the surrounding code (like manual alignment).
Use it with caution. We want to make the change fit into the existing formatting as much as possible.
Prefer calling several tools at the same time to save round-trips.
Prompt:
The current patch diff is:
diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
index f1900c567..429ac20a8 100644
--- a/drivers/usb/atm/cxacru.c
+++ b/drivers/usb/atm/cxacru.c
@@ -700,6 +700,8 @@ static int cxacru_cm(struct cxacru_data *instance, enum cxacru_cm_request cm,
ret = offd;
usb_dbg(instance->usbatm, "cm %#x\n", cm);
fail:
+ if (ret < 0)
+ usb_kill_urb(instance->rcv_urb);
mutex_unlock(&instance->cm_serialize);
err:
return ret;
Use the provided tools to format the patch.
Reply: The current patch already complies with the Linux kernel's coding style, conforms to the surrounding code rules, and successfully passes `checkpatch.pl` with 0 errors and 0 warnings. No further formatting changes are required.
|
| 227/4 |
2026/07/31 07:52 |
llm |
patch-formatter |
0m
Model:
Tokens:
input: 4513
output: 39
thoughts: 121
Thoughts: **Analyzing the `cxacru.c` Patch**
Okay, first things first, I need to understand this patch thoroughly. Let's see, it looks like the target is the `drivers/usb/atm/cxacru.c` file. Given my expertise, I always start by grasping the surrounding code to understand the context of the change. Let me quickly examine `cxacru.c` around line 700 to get a good feel for things. I can use the usual tools for this, either a simple `read-file` command to see the surrounding lines directly, or I might use a `codesearch-definition-source` or `grepper` if I need more targeted information. For now, let's just go with a `read-file` command to look at lines 680 to 720 of `cxacru.c`. That should give me the immediate context I need to proceed.
|
| 228/4 |
2026/07/31 07:52 |
tool |
read-file |
0m
Args: map[File:drivers/usb/atm/cxacru.c FirstLine:680 LineCount:40]
Results: map[Contents: 680: if (rbuf[offb] != cm) {
681: if (printk_ratelimit())
682: usb_err(instance->usbatm, "wrong cm %#x in response to cm %#x\n",
683: rbuf[offb], cm);
684: ret = -EIO;
685: goto fail;
686: }
687: if (rbuf[offb + 1] != CM_STATUS_SUCCESS) {
688: if (printk_ratelimit())
689: usb_err(instance->usbatm, "response to cm %#x failed: %#x\n",
690: cm, rbuf[offb + 1]);
691: ret = -EIO;
692: goto fail;
693: }
694: if (offd >= rsize)
695: break;
696: memcpy(rdata + offd, rbuf + offb + 4, min_t(int, stride, rsize - offd));
697: offd += stride;
698: }
699:
700: ret = offd;
701: usb_dbg(instance->usbatm, "cm %#x\n", cm);
702: fail:
703: mutex_unlock(&instance->cm_serialize);
704: err:
705: return ret;
706: }
707:
708: static int cxacru_cm_get_array(struct cxacru_data *instance, enum cxacru_cm_request cm,
709: u32 *data, int size)
710: {
711: int ret, len;
712: __le32 *buf;
713: int offb;
714: unsigned int offd;
715: const int stride = CMD_PACKET_SIZE / (4 * 2) - 1;
716: int buflen = ((size - 1) / stride + 1 + size * 2) * 4;
717:
718: buf = kmalloc(buflen, GFP_KERNEL);
719: if (!buf)
]
|
| 229/4 |
2026/07/31 07:52 |
llm |
patch-formatter |
0m
Model:
Tokens:
input: 5510
output: 9
thoughts: 20
Thoughts: Here's my attempt at summarizing the thought process, tailored for an expert audience:
**Analyzing the Patch with `checkpatch`**
Alright, let's get down to brass tacks. Before I even *look* at the code with my own eyes β well, not *before*, but as a first step β I'm thinking, "Run `checkpatch`." It's the gatekeeper, the automated sanity check, the thing that'll catch the low-hanging fruit and flag any obvious style violations or potential problems that I, as a human, might miss initially. I want to clear the deck before diving into the nitty-gritty. Get the easy stuff out of the way. It's about efficiency; no need to waste time on a code review if the patch breaks kernel style, is improperly formatted or has a blatantly obvious issue that the tool can flag. This is the first diagnostic scan before any deeper scrutiny takes place.
|
| 230/4 |
2026/07/31 07:52 |
tool |
checkpatch |
0m
Results: map[Output:total: 0 errors, 0 warnings, 8 lines checked
Your patch has no obvious style problems and is ready for submission.
]
|
| 231/4 |
2026/07/31 07:52 |
llm |
patch-formatter |
0m
Model:
Tokens:
input: 5778
output: 26
thoughts: 49
Thoughts: Okay, here's the summary, written as if it's my own thought process:
**Refining the Output**
Hold on a second, before I finalize this, I want to make sure the formatting is absolutely pristine. Is there anything else that can be tweaked to be even cleaner and more professional? I need to eliminate any lingering inefficiencies. Let's explore every last detail.
Also, just to be sure, I should check whether a tool like `patch-diff` can reveal the exact differences made. That way I can be certain the output is perfect.
|
| 232/4 |
2026/07/31 07:52 |
tool |
patch-diff |
0m
Args: map[File:drivers/usb/atm/cxacru.c]
Results: map[Output:diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
index f1900c567..429ac20a8 100644
--- a/drivers/usb/atm/cxacru.c
+++ b/drivers/usb/atm/cxacru.c
@@ -608,105 +608,107 @@ static int cxacru_start_wait_urb(struct urb *urb, struct completion *done,
static int cxacru_cm(struct cxacru_data *instance, enum cxacru_cm_request cm,
u8 *wdata, int wsize, u8 *rdata, int rsize)
{
int ret, actlen;
int offb, offd;
const int stride = CMD_PACKET_SIZE - 4;
u8 *wbuf = instance->snd_buf;
u8 *rbuf = instance->rcv_buf;
int wbuflen = ((wsize - 1) / stride + 1) * CMD_PACKET_SIZE;
int rbuflen = ((rsize - 1) / stride + 1) * CMD_PACKET_SIZE;
if (wbuflen > PAGE_SIZE || rbuflen > PAGE_SIZE) {
if (printk_ratelimit())
usb_err(instance->usbatm, "requested transfer size too large (%d, %d)\n",
wbuflen, rbuflen);
ret = -ENOMEM;
goto err;
}
mutex_lock(&instance->cm_serialize);
/* submit reading urb before the writing one */
init_completion(&instance->rcv_done);
ret = usb_submit_urb(instance->rcv_urb, GFP_KERNEL);
if (ret < 0) {
if (printk_ratelimit())
usb_err(instance->usbatm, "submit of read urb for cm %#x failed (%d)\n",
cm, ret);
goto fail;
}
memset(wbuf, 0, wbuflen);
/* handle wsize == 0 */
wbuf[0] = cm;
for (offb = offd = 0; offd < wsize; offd += stride, offb += CMD_PACKET_SIZE) {
wbuf[offb] = cm;
memcpy(wbuf + offb + 4, wdata + offd, min_t(int, stride, wsize - offd));
}
instance->snd_urb->transfer_buffer_length = wbuflen;
init_completion(&instance->snd_done);
ret = usb_submit_urb(instance->snd_urb, GFP_KERNEL);
if (ret < 0) {
if (printk_ratelimit())
usb_err(instance->usbatm, "submit of write urb for cm %#x failed (%d)\n",
cm, ret);
goto fail;
}
ret = cxacru_start_wait_urb(instance->snd_urb, &instance->snd_done, NULL);
if (ret < 0) {
if (printk_ratelimit())
usb_err(instance->usbatm, "send of cm %#x failed (%d)\n", cm, ret);
goto fail;
}
ret = cxacru_start_wait_urb(instance->rcv_urb, &instance->rcv_done, &actlen);
if (ret < 0) {
if (printk_ratelimit())
usb_err(instance->usbatm, "receive of cm %#x failed (%d)\n", cm, ret);
goto fail;
}
if (actlen % CMD_PACKET_SIZE || !actlen) {
if (printk_ratelimit())
usb_err(instance->usbatm, "invalid response length to cm %#x: %d\n",
cm, actlen);
ret = -EIO;
goto fail;
}
/* check the return status and copy the data to the output buffer, if needed */
for (offb = offd = 0; offd < rsize && offb < actlen; offb += CMD_PACKET_SIZE) {
if (rbuf[offb] != cm) {
if (printk_ratelimit())
usb_err(instance->usbatm, "wrong cm %#x in response to cm %#x\n",
rbuf[offb], cm);
ret = -EIO;
goto fail;
}
if (rbuf[offb + 1] != CM_STATUS_SUCCESS) {
if (printk_ratelimit())
usb_err(instance->usbatm, "response to cm %#x failed: %#x\n",
cm, rbuf[offb + 1]);
ret = -EIO;
goto fail;
}
if (offd >= rsize)
break;
memcpy(rdata + offd, rbuf + offb + 4, min_t(int, stride, rsize - offd));
offd += stride;
}
ret = offd;
usb_dbg(instance->usbatm, "cm %#x\n", cm);
fail:
+ if (ret < 0)
+ usb_kill_urb(instance->rcv_urb);
mutex_unlock(&instance->cm_serialize);
err:
return ret;
}
static int cxacru_cm_get_array(struct cxacru_data *instance, enum cxacru_cm_request cm,
u32 *data, int size)
{
int ret, len;
__le32 *buf;
]
|
| 233/4 |
2026/07/31 07:52 |
llm |
patch-formatter |
0m
Model:
Tokens:
input: 7489
output: 46
thoughts: 193
Thoughts: **Finalizing the Formatting Check**
Okay, so the patch I've got looks good, perfectly formatted. Just to be absolutely certain, even though my initial assessment is positive, I should do another `checkpatch` run. But before I do that, it's probably best to check for anything else that needs addressing in the surrounding files. The user is guiding me. I need to make sure I'm only focusing on formatting, and that the code logic remains unchanged. They've specifically stated that if the patch already checks out with the requested changes, surrounding code rules, and `checkpatch.pl`, then I can just finish up. Since everything seems to be in order, I'm confident that the code already adheres to everything I need to comply with. Therefore, I can simply wrap this up with a clear explanation of what was done, and confirm that it is complete.
|
| 234/3 |
2026/07/31 07:52 |
action |
test-patch-inplace |
0m
Results: map[PatchDiff:diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
index f1900c567..429ac20a8 100644
--- a/drivers/usb/atm/cxacru.c
+++ b/drivers/usb/atm/cxacru.c
@@ -700,6 +700,8 @@ static int cxacru_cm(struct cxacru_data *instance, enum cxacru_cm_request cm,
ret = offd;
usb_dbg(instance->usbatm, "cm %#x\n", cm);
fail:
+ if (ret < 0)
+ usb_kill_urb(instance->rcv_urb);
mutex_unlock(&instance->cm_serialize);
err:
return ret;
TestError:]
|
| 235/3 |
2026/07/31 07:52 |
action |
run-checkpatch |
0m
Results: map[CheckpatchOutput:total: 0 errors, 0 warnings, 8 lines checked
Your patch has no obvious style problems and is ready for submission.
NeedRefinement:false]
|
| 236/1 |
2026/07/31 07:52 |
agent |
fixes-finder |
0m
Model:
Results: map[FixesHash:1b0e614652344a2d39eb336f3dc07651782883bf]
Instruction:
You are an experienced Linux kernel developer tasked with identifying the commit
that introduced the bug being fixed. Identifying the correct buggy commit is crucial
for proper kernel maintenance (backporting to stable trees, etc.).
Your investigation strategy:
1. Examine the patch that fixes the bug. Use git tools (like git-log or git-blame)
to trace the history of the lines or functions modified by the patch.
2. Analyze the stack trace in the crash report. Identify the key files and functions
involved in the crash and investigate their history to see when the problematic
logic was introduced.
3. Compare the bug explanation with the commit history to find the point where
the described logic error first appeared.
A bug is typically introduced when a piece of code is first written, or when
a refactoring changed its logic in a way that introduced the bug.
Trace the history of relevant symbols or find when specific code patterns were introduced/removed.
You must provide exactly one bug-introducing commit hash.
If you are unable to confidently determine the bug-introducing commit after investigation,
return an empty string rather than guessing.
Prefer calling several tools at the same time to save round-trips.
Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.
Prompt:
The crash is:
cxacru 1-1:1.0: send of cm 0x84 failed (-104)
ATM dev 0: cxacru_atm_start: CHIP_ADSL_LINE_START returned -104
------------[ cut here ]------------
URB ffff88812658d200 submitted while active
WARNING: drivers/usb/core/urb.c:379 at usb_submit_urb+0x79/0x18b0 drivers/usb/core/urb.c:379, CPU#1: kworker/1:1/5258
Modules linked in:
CPU: 1 UID: 0 PID: 5258 Comm: kworker/1:1 Not tainted syzkaller #1 PREEMPT(lazy)
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
Workqueue: usb_hub_wq hub_event
RIP: 0010:usb_submit_urb+0x7c/0x18b0 drivers/usb/core/urb.c:379
Code: 4c 89 f0 48 c1 e8 03 80 3c 28 00 74 08 4c 89 f7 e8 c9 ab f6 fc 49 83 3e 00 74 40 e8 9e 5e 91 fc 48 8d 3d 47 b1 aa 05 48 89 de <67> 48 0f b9 3a b8 f0 ff ff ff eb 11 e8 83 5e 91 fc eb 05 e8 7c 5e
RSP: 0018:ffffc90002476878 EFLAGS: 00010293
RAX: ffffffff84f3e532 RBX: ffff88812658d200 RCX: ffff88812fb42440
RDX: 0000000000000000 RSI: ffff88812658d200 RDI: ffffffff8a9e9680
RBP: dffffc0000000000 R08: 0000000000000002 R09: 0000000000000000
R10: dffffc0000000000 R11: fffffbfff152f477 R12: 0000000000000040
R13: 0000000000000000 R14: ffff88812658d208 R15: 0000000000000cc0
FS: 0000000000000000(0000) GS:ffff8882a9042000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f7be0a0cfe0 CR3: 000000011d54e000 CR4: 0000000000350ef0
Call Trace:
<TASK>
cxacru_cm+0x21a/0xf10 drivers/usb/atm/cxacru.c:631
cxacru_cm_get_array drivers/usb/atm/cxacru.c:722 [inline]
cxacru_poll_status+0x178/0x1110 drivers/usb/atm/cxacru.c:828
cxacru_atm_start+0x185/0x360 drivers/usb/atm/cxacru.c:814
usbatm_atm_init+0x144/0x3a0 drivers/usb/atm/usbatm.c:927
usbatm_usb_probe+0x15cb/0x1db0 drivers/usb/atm/usbatm.c:1178
cxacru_usb_probe+0x17f/0x220 drivers/usb/atm/cxacru.c:1370
usb_probe_interface+0x653/0xc60 drivers/usb/core/driver.c:396
call_driver_probe drivers/base/dd.c:-1 [inline]
really_probe+0x254/0xae0 drivers/base/dd.c:706
__driver_probe_device+0x1e8/0x360 drivers/base/dd.c:868
driver_probe_device+0x4f/0x240 drivers/base/dd.c:898
__device_attach_driver+0x270/0x410 drivers/base/dd.c:1026
bus_for_each_drv+0x258/0x2f0 drivers/base/bus.c:500
__device_attach+0x2c4/0x450 drivers/base/dd.c:1098
device_initial_probe+0xa1/0xd0 drivers/base/dd.c:1153
bus_probe_device+0x12a/0x220 drivers/base/bus.c:620
device_add+0x7d7/0xb80 drivers/base/core.c:3772
usb_set_configuration+0x1ad8/0x2180 drivers/usb/core/message.c:2268
usb_generic_driver_probe+0x8d/0x150 drivers/usb/core/generic.c:250
usb_probe_device+0x1c3/0x3b0 drivers/usb/core/driver.c:291
call_driver_probe drivers/base/dd.c:-1 [inline]
really_probe+0x254/0xae0 drivers/base/dd.c:706
__driver_probe_device+0x1e8/0x360 drivers/base/dd.c:868
driver_probe_device+0x4f/0x240 drivers/base/dd.c:898
__device_attach_driver+0x270/0x410 drivers/base/dd.c:1026
bus_for_each_drv+0x258/0x2f0 drivers/base/bus.c:500
__device_attach+0x2c4/0x450 drivers/base/dd.c:1098
device_initial_probe+0xa1/0xd0 drivers/base/dd.c:1153
bus_probe_device+0x12a/0x220 drivers/base/bus.c:620
device_add+0x7d7/0xb80 drivers/base/core.c:3772
usb_new_device+0x99d/0x1620 drivers/usb/core/hub.c:2695
hub_port_connect drivers/usb/core/hub.c:5567 [inline]
hub_port_connect_change drivers/usb/core/hub.c:5707 [inline]
port_event drivers/usb/core/hub.c:5871 [inline]
hub_event+0x28e8/0x4d30 drivers/usb/core/hub.c:5953
process_one_work kernel/workqueue.c:3322 [inline]
process_scheduled_works+0xa8e/0x14e0 kernel/workqueue.c:3405
worker_thread+0x92d/0xe10 kernel/workqueue.c:3486
kthread+0x388/0x470 kernel/kthread.c:436
ret_from_fork+0x491/0xad0 arch/x86/kernel/process.c:158
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
</TASK>
----------------
Code disassembly (best guess):
0: 4c 89 f0 mov %r14,%rax
3: 48 c1 e8 03 shr $0x3,%rax
7: 80 3c 28 00 cmpb $0x0,(%rax,%rbp,1)
b: 74 08 je 0x15
d: 4c 89 f7 mov %r14,%rdi
10: e8 c9 ab f6 fc call 0xfcf6abde
15: 49 83 3e 00 cmpq $0x0,(%r14)
19: 74 40 je 0x5b
1b: e8 9e 5e 91 fc call 0xfc915ebe
20: 48 8d 3d 47 b1 aa 05 lea 0x5aab147(%rip),%rdi # 0x5aab16e
27: 48 89 de mov %rbx,%rsi
* 2a: 67 48 0f b9 3a ud1 (%edx),%rdi <-- trapping instruction
2f: b8 f0 ff ff ff mov $0xfffffff0,%eax
34: eb 11 jmp 0x47
36: e8 83 5e 91 fc call 0xfc915ebe
3b: eb 05 jmp 0x42
3d: e8 .byte 0xe8
3e: 7c 5e jl 0x9e
The explanation of the root cause is:
The root cause of this bug is that `cxacru_cm()` leaves `rcv_urb` active if it encounters an error while submitting or waiting for `snd_urb`.
Here is the exact sequence of events that leads to the crash:
1. `cxacru_atm_start()` calls `cxacru_cm()` to send the `CM_REQUEST_CHIP_ADSL_LINE_START` (`0x84`) command.
2. Inside `cxacru_cm()`, `rcv_urb` is successfully submitted first (line 631).
3. Then, `snd_urb` is submitted and `cxacru_cm()` waits for its completion via `cxacru_start_wait_urb()` (line 657).
4. In the syzkaller reproducer, the USB device behaves unexpectedly (e.g., endpoint stall or disconnect), causing `snd_urb` to complete with an error status of `-104` (`-ECONNRESET`).
5. `cxacru_start_wait_urb()` returns this `-104` error, which prompts `cxacru_cm()` to print `"send of cm 0x84 failed (-104)"` and jump to the `fail:` label (line 661).
6. At the `fail:` label, `cxacru_cm()` simply unlocks the mutex and returns the error, **leaving `rcv_urb` still active and pending**.
7. Back in `cxacru_atm_start()`, the error is printed (`"CHIP_ADSL_LINE_START returned -104"`) but ignored, and the driver proceeds to start status polling by calling `cxacru_poll_status()`.
8. `cxacru_poll_status()` immediately calls `cxacru_cm_get_array()`, which invokes `cxacru_cm()` again.
9. `cxacru_cm()` attempts to submit `rcv_urb` again, but since it was never unlinked or waited for in the previous failed call, it is still active. This triggers the `URB ... submitted while active` warning in `usb_submit_urb()`.
### Fix
To fix this bug, we need to ensure that `rcv_urb` is properly killed if `cxacru_cm()` aborts early. We can safely call `usb_kill_urb()` on `rcv_urb` in the error path. `usb_kill_urb()` is safe to call even if the URB is not active (e.g., if it failed to submit in the first place, or if it already completed), so it can be called unconditionally on error.
```c
--- a/drivers/usb/atm/cxacru.c
+++ b/drivers/usb/atm/cxacru.c
@@ -700,6 +700,8 @@ static int cxacru_cm(struct cxacru_data *instance, enum cxacru_cm_request cm,
ret = offd;
usb_dbg(instance->usbatm, "cm %#x\n", cm);
fail:
+ if (ret < 0)
+ usb_kill_urb(instance->rcv_urb);
mutex_unlock(&instance->cm_serialize);
err:
return ret;
```
The patch that fixes the bug is:
diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
index f1900c567..429ac20a8 100644
--- a/drivers/usb/atm/cxacru.c
+++ b/drivers/usb/atm/cxacru.c
@@ -700,6 +700,8 @@ static int cxacru_cm(struct cxacru_data *instance, enum cxacru_cm_request cm,
ret = offd;
usb_dbg(instance->usbatm, "cm %#x\n", cm);
fail:
+ if (ret < 0)
+ usb_kill_urb(instance->rcv_urb);
mutex_unlock(&instance->cm_serialize);
err:
return ret;
Search for the commit(s) that introduced this bug.
|
| 237/2 |
2026/07/31 07:52 |
llm |
fixes-finder |
0m
Model:
Tokens:
input: 7529
output: 40
thoughts: 182
Thoughts: **Pinpointing the Root Cause of the cxacru_cm Bug**
Alright, let's tackle this `cxacru_cm()` bug. The core of the problem, as I understand it, lies in `rcv_urb` remaining active when submitting or waiting for `snd_urb` fails within that function. My task now is to trace the origins of this flaw. Specifically, the proposed fix, adding `usb_kill_urb(instance->rcv_urb);` at the `fail:` label, will be crucial in my investigation.
My first step is to dive into the source code itself, focusing on `drivers/usb/atm/cxacru.c`. Then, the real detective work begins. I'll leverage the power of `git-log` or `git-blame` on that file to reconstruct the evolution of `cxacru_cm()`. I want to identify the exact commit β or commits β that introduced this vulnerability. I'm looking for the modification that either introduced the logic flaw directly or, more subtly, changed something in the surrounding code that exposed this bug. Understanding the history is the key to fixing this. I need to understand when and how the critical code was introduced or modified.
|
| 238/2 |
2026/07/31 07:52 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/usb/atm/cxacru.c Name:cxacru_cm]
Results: map[SourceCode: 608: static int cxacru_cm(struct cxacru_data *instance, enum cxacru_cm_request cm,
609: u8 *wdata, int wsize, u8 *rdata, int rsize)
610: {
611: int ret, actlen;
612: int offb, offd;
613: const int stride = CMD_PACKET_SIZE - 4;
614: u8 *wbuf = instance->snd_buf;
615: u8 *rbuf = instance->rcv_buf;
616: int wbuflen = ((wsize - 1) / stride + 1) * CMD_PACKET_SIZE;
617: int rbuflen = ((rsize - 1) / stride + 1) * CMD_PACKET_SIZE;
618:
619: if (wbuflen > PAGE_SIZE || rbuflen > PAGE_SIZE) {
620: if (printk_ratelimit())
621: usb_err(instance->usbatm, "requested transfer size too large (%d, %d)\n",
622: wbuflen, rbuflen);
623: ret = -ENOMEM;
624: goto err;
625: }
626:
627: mutex_lock(&instance->cm_serialize);
628:
629: /* submit reading urb before the writing one */
630: init_completion(&instance->rcv_done);
631: ret = usb_submit_urb(instance->rcv_urb, GFP_KERNEL);
632: if (ret < 0) {
633: if (printk_ratelimit())
634: usb_err(instance->usbatm, "submit of read urb for cm %#x failed (%d)\n",
635: cm, ret);
636: goto fail;
637: }
638:
639: memset(wbuf, 0, wbuflen);
640: /* handle wsize == 0 */
641: wbuf[0] = cm;
642: for (offb = offd = 0; offd < wsize; offd += stride, offb += CMD_PACKET_SIZE) {
643: wbuf[offb] = cm;
644: memcpy(wbuf + offb + 4, wdata + offd, min_t(int, stride, wsize - offd));
645: }
646:
647: instance->snd_urb->transfer_buffer_length = wbuflen;
648: init_completion(&instance->snd_done);
649: ret = usb_submit_urb(instance->snd_urb, GFP_KERNEL);
650: if (ret < 0) {
651: if (printk_ratelimit())
652: usb_err(instance->usbatm, "submit of write urb for cm %#x failed (%d)\n",
653: cm, ret);
654: goto fail;
655: }
656:
657: ret = cxacru_start_wait_urb(instance->snd_urb, &instance->snd_done, NULL);
658: if (ret < 0) {
659: if (printk_ratelimit())
660: usb_err(instance->usbatm, "send of cm %#x failed (%d)\n", cm, ret);
661: goto fail;
662: }
663:
664: ret = cxacru_start_wait_urb(instance->rcv_urb, &instance->rcv_done, &actlen);
665: if (ret < 0) {
666: if (printk_ratelimit())
667: usb_err(instance->usbatm, "receive of cm %#x failed (%d)\n", cm, ret);
668: goto fail;
669: }
670: if (actlen % CMD_PACKET_SIZE || !actlen) {
671: if (printk_ratelimit())
672: usb_err(instance->usbatm, "invalid response length to cm %#x: %d\n",
673: cm, actlen);
674: ret = -EIO;
675: goto fail;
676: }
677:
678: /* check the return status and copy the data to the output buffer, if needed */
679: for (offb = offd = 0; offd < rsize && offb < actlen; offb += CMD_PACKET_SIZE) {
680: if (rbuf[offb] != cm) {
681: if (printk_ratelimit())
682: usb_err(instance->usbatm, "wrong cm %#x in response to cm %#x\n",
683: rbuf[offb], cm);
684: ret = -EIO;
685: goto fail;
686: }
687: if (rbuf[offb + 1] != CM_STATUS_SUCCESS) {
688: if (printk_ratelimit())
689: usb_err(instance->usbatm, "response to cm %#x failed: %#x\n",
690: cm, rbuf[offb + 1]);
691: ret = -EIO;
692: goto fail;
693: }
694: if (offd >= rsize)
695: break;
696: memcpy(rdata + offd, rbuf + offb + 4, min_t(int, stride, rsize - offd));
697: offd += stride;
698: }
699:
700: ret = offd;
701: usb_dbg(instance->usbatm, "cm %#x\n", cm);
702: fail:
703: mutex_unlock(&instance->cm_serialize);
704: err:
705: return ret;
706: }
SourceFile:drivers/usb/atm/cxacru.c]
|
| 239/2 |
2026/07/31 07:52 |
llm |
fixes-finder |
0m
Model:
Tokens:
input: 9742
output: 38
thoughts: 113
Thoughts: **Analyzing the cxacru_cm Bug**
Okay, so the issue boils down to a race condition with `rcv_urb`. I see that it's submitted earlier, specifically at line 631. Then, if either `usb_submit_urb` on the `snd_urb` fails at 649, or `cxacru_start_wait_urb` fails at 657, the code jumps to the `fail:` label. The critical bit here is that the mutex gets unlocked *before* we deal with the still-active `rcv_urb`. That's bad. That means the receive URB is potentially running without proper protection, leading to data corruption or other nasty side effects, depending on the kernel version and driver.
Time to dig into the history of `cxacru_cm`. I need to see how and why that `rcv_urb` submission was put there in the first place, and what assumptions were made about its lifecycle in relation to the `snd_urb` and the mutex. I'm going to look for any related changes or fixes that might shed light on this, and also how other drivers handle similar scenarios. I need to be sure before I make any suggestions on what needs to be changed.
|
| 240/2 |
2026/07/31 07:53 |
tool |
git-log |
0m
Error:
Args: map[PathPrefix:drivers/usb/atm/cxacru.c SymbolName:cxacru_cm]
Results:
|
| 241/2 |
2026/07/31 07:53 |
llm |
fixes-finder |
0m
Model:
Tokens:
input: 10183
output: 38
thoughts: 20
Thoughts: Okay, here's my summary, tailored as if I'm an expert in the field thinking through this:
**Refining My Approach to Symbol Resolution**
Right, as I'm thinking through this, it just clicked. Using `SourcePath` is definitely the right move, rather than sticking with `PathPrefix` for `SymbolName`. It feels like a cleaner and more direct approach for resolving the symbol. The conceptual model is more accurate, and that's going to simplify things down the line. It's subtle, but it will make for more clarity, more consistency in the code, and should make debugging a whole lot easier. Plus, this might offer future extensibility, which is always something to consider. Yes, `SourcePath` is the superior option here.
|
| 242/2 |
2026/07/31 07:53 |
tool |
git-log |
0m
Args: map[SourcePath:drivers/usb/atm/cxacru.c SymbolName:cxacru_cm]
Results: map[Output:c68bb0d73889 USB: cxacru: document how to interact with the flash memory
1b0e61465234 [PATCH] USB ATM: driver for the Conexant AccessRunner chipset cxacru
]
|
| 243/2 |
2026/07/31 07:53 |
llm |
fixes-finder |
0m
Model:
Tokens:
input: 10473
output: 27
thoughts: 38
Thoughts: Here's my analysis of the commit `1b0e61465234 [PATCH] USB ATM: driver for the Conexant AccessRunner chipset cxacru`:
**Analyzing a USB ATM Driver Commit**
Okay, so I'm looking at commit `1b0e61465234`. The subject line, "[PATCH] USB ATM: driver for the Conexant AccessRunner chipset cxacru," immediately tells me a few things. First, it's a *patch*, meaning a proposed change or addition to the existing codebase, which is standard procedure. Second, it concerns a USB ATM driver. ATM, Asynchronous Transfer Mode, brings up thoughts of older networking technologies, possibly interesting for legacy system support or specific embedded applications. Third, the driver is specifically for the Conexant AccessRunner chipset, cxacru, which is helpful context.
I'd want to quickly assess a few things. First, *is* there an existing driver? Perhaps this is a rewrite, an improvement, or an initial implementation. I'd go to the codebase and see if it's new code being added or existing code being modified. From there, I'd dig into the actual code changes within the patch. I'd pay close attention to the interface with the USB subsystem, specifically the interaction with the USB device and how the ATM layer is mapped onto the USB protocol. The cxacru chipset's specifications and datasheets would be useful for that analysis. I'll need to figure out what protocols are supported. Is it AAL5? Does it handle traffic shaping?
I would also consider its interaction with the existing kernel ATM stack. Does it adhere to the standard ATM network interface (e.g., how the VPI/VCI values are handled)? How does it interface with upper-layer network protocols? Memory management within the driver is a primary consideration, along with interrupt handling within the USB driver. Then, if this is for the mainline kernel, I would be looking for the robustness, maintainability, and security implications of this commit. Finally, whatβs the stated purpose of the driver? Is it for end-user consumer equipment or specific embedded systems? Answering that would help put the design within the correct context.
|
| 244/2 |
2026/07/31 07:53 |
tool |
git-show |
0m
Args:
Results: map[Output:commit 1b0e614652344a2d39eb336f3dc07651782883bf
Author: Duncan Sands <duncan.sands@math.u-psud.fr>
Date: Wed May 11 20:19:29 2005 +0200
[PATCH] USB ATM: driver for the Conexant AccessRunner chipset cxacru
Driver for modems based on the Conexant AccessRunner chipset.
Original patch by Josep Comas, much reworked by Roman Kagan.
Signed-off-by: Duncan Sands <baldrick@free.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
new file mode 100644
index 000000000000..cbd4a7d25d0b
--- /dev/null
+++ b/drivers/usb/atm/cxacru.c
@@ -0,0 +1,878 @@
+/******************************************************************************
+ * cxacru.c - driver for USB ADSL modems based on
+ * Conexant AccessRunner chipset
+ *
+ * Copyright (C) 2004 David Woodhouse, Duncan Sands, Roman Kagan
+ * Copyright (C) 2005 Duncan Sands, Roman Kagan (rkagan % mail ! ru)
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59
+ * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ ******************************************************************************/
+
+/*
+ * Credit is due for Josep Comas, who created the original patch to speedtch.c
+ * to support the different padding used by the AccessRunner (now generalized
+ * into usbatm), and the userspace firmware loading utility.
+ */
+
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/kernel.h>
+#include <linux/timer.h>
+#include <linux/errno.h>
+#include <linux/slab.h>
+#include <linux/init.h>
+#include <linux/device.h> /* FIXME: linux/firmware.h should include it itself */
+#include <linux/firmware.h>
+
+#include "usbatm.h"
+
+#define DRIVER_AUTHOR "Roman Kagan, David Woodhouse, Duncan Sands"
+#define DRIVER_VERSION "0.2"
+#define DRIVER_DESC "Conexant AccessRunner ADSL USB modem driver"
+
+static const char cxacru_driver_name[] = "cxacru";
+
+#define CXACRU_EP_CMD 0x01 /* Bulk/interrupt in/out */
+#define CXACRU_EP_DATA 0x02 /* Bulk in/out */
+
+#define CMD_PACKET_SIZE 64 /* Should be maxpacket(ep)? */
+
+/* Addresses */
+#define PLLFCLK_ADDR 0x00350068
+#define PLLBCLK_ADDR 0x0035006c
+#define SDRAMEN_ADDR 0x00350010
+#define FW_ADDR 0x00801000
+#define BR_ADDR 0x00180600
+#define SIG_ADDR 0x00180500
+#define BR_STACK_ADDR 0x00187f10
+
+/* Values */
+#define SDRAM_ENA 0x1
+
+#define CMD_TIMEOUT 2000 /* msecs */
+#define POLL_INTERVAL 5000 /* msecs */
+
+/* commands for interaction with the modem through the control channel before
+ * firmware is loaded */
+enum cxacru_fw_request {
+ FW_CMD_ERR,
+ FW_GET_VER,
+ FW_READ_MEM,
+ FW_WRITE_MEM,
+ FW_RMW_MEM,
+ FW_CHECKSUM_MEM,
+ FW_GOTO_MEM,
+};
+
+/* commands for interaction with the modem through the control channel once
+ * firmware is loaded */
+enum cxacru_cm_request {
+ CM_REQUEST_UNDEFINED = 0x80,
+ CM_REQUEST_TEST,
+ CM_REQUEST_CHIP_GET_MAC_ADDRESS,
+ CM_REQUEST_CHIP_GET_DP_VERSIONS,
+ CM_REQUEST_CHIP_ADSL_LINE_START,
+ CM_REQUEST_CHIP_ADSL_LINE_STOP,
+ CM_REQUEST_CHIP_ADSL_LINE_GET_STATUS,
+ CM_REQUEST_CHIP_ADSL_LINE_GET_SPEED,
+ CM_REQUEST_CARD_INFO_GET,
+ CM_REQUEST_CARD_DATA_GET,
+ CM_REQUEST_CARD_DATA_SET,
+ CM_REQUEST_COMMAND_HW_IO,
+ CM_REQUEST_INTERFACE_HW_IO,
+ CM_REQUEST_CARD_SERIAL_DATA_PATH_GET,
+ CM_REQUEST_CARD_SERIAL_DATA_PATH_SET,
+ CM_REQUEST_CARD_CONTROLLER_VERSION_GET,
+ CM_REQUEST_CARD_GET_STATUS,
+ CM_REQUEST_CARD_GET_MAC_ADDRESS,
+ CM_REQUEST_CARD_GET_DATA_LINK_STATUS,
+ CM_REQUEST_MAX,
+};
+
+/* reply codes to the commands above */
+enum cxacru_cm_status {
+ CM_STATUS_UNDEFINED,
+ CM_STATUS_SUCCESS,
+ CM_STATUS_ERROR,
+ CM_STATUS_UNSUPPORTED,
+ CM_STATUS_UNIMPLEMENTED,
+ CM_STATUS_PARAMETER_ERROR,
+ CM_STATUS_DBG_LOOPBACK,
+ CM_STATUS_MAX,
+};
+
+/* indices into CARD_INFO_GET return array */
+enum cxacru_info_idx {
+ CXINF_DOWNSTREAM_RATE,
+ CXINF_UPSTREAM_RATE,
+ CXINF_LINK_STATUS,
+ CXINF_LINE_STATUS,
+ CXINF_MAC_ADDRESS_HIGH,
+ CXINF_MAC_ADDRESS_LOW,
+ CXINF_UPSTREAM_SNR_MARGIN,
+ CXINF_DOWNSTREAM_SNR_MARGIN,
+ CXINF_UPSTREAM_ATTENUATION,
+ CXINF_DOWNSTREAM_ATTENUATION,
+ CXINF_TRANSMITTER_POWER,
+ CXINF_UPSTREAM_BITS_PER_FRAME,
+ CXINF_DOWNSTREAM_BITS_PER_FRAME,
+ CXINF_STARTUP_ATTEMPTS,
+ CXINF_UPSTREAM_CRC_ERRORS,
+ CXINF_DOWNSTREAM_CRC_ERRORS,
+ CXINF_UPSTREAM_FEC_ERRORS,
+ CXINF_DOWNSTREAM_FEC_ERRORS,
+ CXINF_UPSTREAM_HEC_ERRORS,
+ CXINF_DOWNSTREAM_HEC_ERRORS,
+ CXINF_LINE_STARTABLE,
+ CXINF_MODULATION,
+ CXINF_ADSL_HEADEND,
+ CXINF_ADSL_HEADEND_ENVIRONMENT,
+ CXINF_CONTROLLER_VERSION,
+ /* dunno what the missing two mean */
+ CXINF_MAX = 0x1c,
+};
+
+struct cxacru_modem_type {
+ u32 pll_f_clk;
+ u32 pll_b_clk;
+ int boot_rom_patch;
+};
+
+struct cxacru_data {
+ struct usbatm_data *usbatm;
+
+ const struct cxacru_modem_type *modem_type;
+
+ int line_status;
+ struct work_struct poll_work;
+
+ /* contol handles */
+ struct semaphore cm_serialize;
+ u8 *rcv_buf;
+ u8 *snd_buf;
+ struct urb *rcv_urb;
+ struct urb *snd_urb;
+ struct completion rcv_done;
+ struct completion snd_done;
+};
+
+/* the following three functions are stolen from drivers/usb/core/message.c */
+static void cxacru_blocking_completion(struct urb *urb, struct pt_regs *regs)
+{
+ complete((struct completion *)urb->context);
+}
+
+static void cxacru_timeout_kill(unsigned long data)
+{
+ usb_unlink_urb((struct urb *) data);
+}
+
+static int cxacru_start_wait_urb(struct urb *urb, struct completion *done,
+ int* actual_length)
+{
+ struct timer_list timer;
+ int status;
+
+ init_timer(&timer);
+ timer.expires = jiffies + msecs_to_jiffies(CMD_TIMEOUT);
+ timer.data = (unsigned long) urb;
+ timer.function = cxacru_timeout_kill;
+ add_timer(&timer);
+ wait_for_completion(done);
+ status = urb->status;
+ if (status == -ECONNRESET)
+ status = -ETIMEDOUT;
+ del_timer_sync(&timer);
+
+ if (actual_length)
+ *actual_length = urb->actual_length;
+ return status;
+}
+
+static int cxacru_cm(struct cxacru_data *instance, enum cxacru_cm_request cm,
+ u8 *wdata, int wsize, u8 *rdata, int rsize)
+{
+ int ret, actlen;
+ int offb, offd;
+ const int stride = CMD_PACKET_SIZE - 4;
+ u8 *wbuf = instance->snd_buf;
+ u8 *rbuf = instance->rcv_buf;
+ int wbuflen = ((wsize - 1) / stride + 1) * CMD_PACKET_SIZE;
+ int rbuflen = ((rsize - 1) / stride + 1) * CMD_PACKET_SIZE;
+
+ if (wbuflen > PAGE_SIZE || rbuflen > PAGE_SIZE) {
+ dbg("too big transfer requested");
+ ret = -ENOMEM;
+ goto fail;
+ }
+
+ down(&instance->cm_serialize);
+
+ /* submit reading urb before the writing one */
+ init_completion(&instance->rcv_done);
+ ret = usb_submit_urb(instance->rcv_urb, GFP_KERNEL);
+ if (ret < 0) {
+ dbg("submitting read urb for cm %#x failed", cm);
+ ret = ret;
+ goto fail;
+ }
+
+ memset(wbuf, 0, wbuflen);
+ /* handle wsize == 0 */
+ wbuf[0] = cm;
+ for (offb = offd = 0; offd < wsize; offd += stride, offb += CMD_PACKET_SIZE) {
+ wbuf[offb] = cm;
+ memcpy(wbuf + offb + 4, wdata + offd, min_t(int, stride, wsize - offd));
+ }
+
+ instance->snd_urb->transfer_buffer_length = wbuflen;
+ init_completion(&instance->snd_done);
+ ret = usb_submit_urb(instance->snd_urb, GFP_KERNEL);
+ if (ret < 0) {
+ dbg("submitting write urb for cm %#x failed", cm);
+ ret = ret;
+ goto fail;
+ }
+
+ ret = cxacru_start_wait_urb(instance->snd_urb, &instance->snd_done, NULL);
+ if (ret < 0) {
+ dbg("sending cm %#x failed", cm);
+ ret = ret;
+ goto fail;
+ }
+
+ ret = cxacru_start_wait_urb(instance->rcv_urb, &instance->rcv_done, &actlen);
+ if (ret < 0) {
+ dbg("receiving cm %#x failed", cm);
+ ret = ret;
+ goto fail;
+ }
+ if (actlen % CMD_PACKET_SIZE || !actlen) {
+ dbg("response is not a positive multiple of %d: %#x",
+ CMD_PACKET_SIZE, actlen);
+ ret = -EIO;
+ goto fail;
+ }
+
+ /* check the return status and copy the data to the output buffer, if needed */
+ for (offb = offd = 0; offd < rsize && offb < actlen; offb += CMD_PACKET_SIZE) {
+ if (rbuf[offb] != cm) {
+ dbg("wrong cm %#x in response", rbuf[offb]);
+ ret = -EIO;
+ goto fail;
+ }
+ if (rbuf[offb + 1] != CM_STATUS_SUCCESS) {
+ dbg("response failed: %#x", rbuf[offb + 1]);
+ ret = -EIO;
+ goto fail;
+ }
+ if (offd >= rsize)
+ break;
+ memcpy(rdata + offd, rbuf + offb + 4, min_t(int, stride, rsize - offd));
+ offd += stride;
+ }
+
+ ret = offd;
+ dbg("cm %#x", cm);
+fail:
+ up(&instance->cm_serialize);
+ return ret;
+}
+
+static int cxacru_cm_get_array(struct cxacru_data *instance, enum cxacru_cm_request cm,
+ u32 *data, int size)
+{
+ int ret, len;
+ u32 *buf;
+ int offb, offd;
+ const int stride = CMD_PACKET_SIZE / (4 * 2) - 1;
+ int buflen = ((size - 1) / stride + 1 + size * 2) * 4;
+
+ buf = kmalloc(buflen, GFP_KERNEL);
+ if (!buf)
+ return -ENOMEM;
+
+ ret = cxacru_cm(instance, cm, NULL, 0, (u8 *) buf, buflen);
+ if (ret < 0)
+ goto cleanup;
+
+ /* len > 0 && len % 4 == 0 guaranteed by cxacru_cm() */
+ len = ret / 4;
+ for (offb = 0; offb < len; ) {
+ int l = le32_to_cpu(buf[offb++]);
+ if (l > stride || l > (len - offb) / 2) {
+ dbg("wrong data length %#x in response", l);
+ ret = -EIO;
+ goto cleanup;
+ }
+ while (l--) {
+ offd = le32_to_cpu(buf[offb++]);
+ if (offd >= size) {
+ dbg("wrong index %#x in response", offd);
+ ret = -EIO;
+ goto cleanup;
+ }
+ data[offd] = le32_to_cpu(buf[offb++]);
+ }
+ }
+
+ ret = 0;
+
+cleanup:
+ kfree(buf);
+ return ret;
+}
+
+static int cxacru_card_status(struct cxacru_data *instance)
+{
+ int ret = cxacru_cm(instance, CM_REQUEST_CARD_GET_STATUS, NULL, 0, NULL, 0);
+ if (ret < 0) { /* firmware not loaded */
+ dbg("cxacru_adsl_start: CARD_GET_STATUS returned %d", ret);
+ return ret;
+ }
+ return 0;
+}
+
+static void cxacru_poll_status(struct cxacru_data *instance);
+
+static int cxacru_atm_start(struct usbatm_data *usbatm_instance,
+ struct atm_dev *atm_dev)
+{
+ struct cxacru_data *instance = usbatm_instance->driver_data;
+ struct device *dev = &usbatm_instance->usb_intf->dev;
+ /*
+ struct atm_dev *atm_dev = usbatm_instance->atm_dev;
+ */
+ int ret;
+
+ dbg("cxacru_atm_start");
+
+ /* Read MAC address */
+ ret = cxacru_cm(instance, CM_REQUEST_CARD_GET_MAC_ADDRESS, NULL, 0,
+ atm_dev->esi, sizeof(atm_dev->esi));
+ if (ret < 0) {
+ dev_err(dev, "cxacru_atm_start: CARD_GET_MAC_ADDRESS returned %d\n", ret);
+ return ret;
+ }
+
+ /* start ADSL */
+ ret = cxacru_cm(instance, CM_REQUEST_CHIP_ADSL_LINE_START, NULL, 0, NULL, 0);
+ if (ret < 0) {
+ dev_err(dev, "cxacru_atm_start: CHIP_ADSL_LINE_START returned %d\n", ret);
+ return ret;
+ }
+
+ /* Start status polling */
+ cxacru_poll_status(instance);
+ return 0;
+}
+
+static void cxacru_poll_status(struct cxacru_data *instance)
+{
+ u32 buf[CXINF_MAX] = {};
+ struct device *dev = &instance->usbatm->usb_intf->dev;
+ struct atm_dev *atm_dev = instance->usbatm->atm_dev;
+ int ret;
+
+ ret = cxacru_cm_get_array(instance, CM_REQUEST_CARD_INFO_GET, buf, CXINF_MAX);
+ if (ret < 0) {
+ dev_warn(dev, "poll status: error %d\n", ret);
+ goto reschedule;
+ }
+
+ if (instance->line_status == buf[CXINF_LINE_STATUS])
+ goto reschedule;
+
+ instance->line_status = buf[CXINF_LINE_STATUS];
+ switch (instance->line_status) {
+ case 0:
+ atm_dev->signal = ATM_PHY_SIG_LOST;
+ dev_info(dev, "ADSL line: down\n");
+ break;
+
+ case 1:
+ atm_dev->signal = ATM_PHY_SIG_LOST;
+ dev_info(dev, "ADSL line: attemtping to activate\n");
+ break;
+
+ case 2:
+ atm_dev->signal = ATM_PHY_SIG_LOST;
+ dev_info(dev, "ADSL line: training\n");
+ break;
+
+ case 3:
+ atm_dev->signal = ATM_PHY_SIG_LOST;
+ dev_info(dev, "ADSL line: channel analysis\n");
+ break;
+
+ case 4:
+ atm_dev->signal = ATM_PHY_SIG_LOST;
+ dev_info(dev, "ADSL line: exchange\n");
+ break;
+
+ case 5:
+ atm_dev->link_rate = buf[CXINF_DOWNSTREAM_RATE] * 1000 / 424;
+ atm_dev->signal = ATM_PHY_SIG_FOUND;
+
+ dev_info(dev, "ADSL line: up (%d Kib/s down | %d Kib/s up)\n",
+ buf[CXINF_DOWNSTREAM_RATE], buf[CXINF_UPSTREAM_RATE]);
+ break;
+
+ case 6:
+ atm_dev->signal = ATM_PHY_SIG_LOST;
+ dev_info(dev, "ADSL line: waiting\n");
+ break;
+
+ case 7:
+ atm_dev->signal = ATM_PHY_SIG_LOST;
+ dev_info(dev, "ADSL line: initializing\n");
+ break;
+
+ default:
+ atm_dev->signal = ATM_PHY_SIG_UNKNOWN;
+ dev_info(dev, "Unknown line state %02x\n", instance->line_status);
+ break;
+ }
+reschedule:
+ schedule_delayed_work(&instance->poll_work, msecs_to_jiffies(POLL_INTERVAL));
+}
+
+static int cxacru_fw(struct usb_device *usb_dev, enum cxacru_fw_request fw,
+ u8 code1, u8 code2, u32 addr, u8 *data, int size)
+{
+ int ret;
+ u8 *buf;
+ int offd, offb;
+ const int stride = CMD_PACKET_SIZE - 8;
+
+ buf = (u8 *) __get_free_page(GFP_KERNEL);
+ if (!buf)
+ return -ENOMEM;
+
+ offb = offd = 0;
+ do {
+ int l = min_t(int, stride, size - offd);
+ buf[offb++] = fw;
+ buf[offb++] = l;
+ buf[offb++] = code1;
+ buf[offb++] = code2;
+ *((u32 *) (buf + offb)) = cpu_to_le32(addr);
+ offb += 4;
+ addr += l;
+ if(l)
+ memcpy(buf + offb, data + offd, l);
+ if (l < stride)
+ memset(buf + offb + l, 0, stride - l);
+ offb += stride;
+ offd += stride;
+ if ((offb >= PAGE_SIZE) || (offd >= size)) {
+ ret = usb_bulk_msg(usb_dev, usb_sndbulkpipe(usb_dev, CXACRU_EP_CMD),
+ buf, offb, NULL, CMD_TIMEOUT);
+ if (ret < 0) {
+ dbg("sending fw %#x failed", fw);
+ goto cleanup;
+ }
+ offb = 0;
+ }
+ } while(offd < size);
+ dbg("sent fw %#x", fw);
+
+ ret = 0;
+
+cleanup:
+ free_page((unsigned long) buf);
+ return ret;
+}
+
+static void cxacru_upload_firmware(struct cxacru_data *instance,
+ const struct firmware *fw,
+ const struct firmware *bp,
+ const struct firmware *cf)
+{
+ int ret;
+ int off;
+ struct usb_device *usb_dev = instance->usbatm->usb_dev;
+ struct device *dev = &instance->usbatm->usb_intf->dev;
+ u16 signature[] = { usb_dev->descriptor.idVendor, usb_dev->descriptor.idProduct };
+ u32 val;
+
+ dbg("cxacru_upload_firmware");
+
+ /* FirmwarePllFClkValue */
+ val = cpu_to_le32(instance->modem_type->pll_f_clk);
+ ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, PLLFCLK_ADDR, (u8 *) &val, 4);
+ if (ret) {
+ dev_err(dev, "FirmwarePllFClkValue failed: %d\n", ret);
+ return;
+ }
+
+ /* FirmwarePllBClkValue */
+ val = cpu_to_le32(instance->modem_type->pll_b_clk);
+ ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, PLLBCLK_ADDR, (u8 *) &val, 4);
+ if (ret) {
+ dev_err(dev, "FirmwarePllBClkValue failed: %d\n", ret);
+ return;
+ }
+
+ /* Enable SDRAM */
+ val = cpu_to_le32(SDRAM_ENA);
+ ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, SDRAMEN_ADDR, (u8 *) &val, 4);
+ if (ret) {
+ dev_err(dev, "Enable SDRAM failed: %d\n", ret);
+ return;
+ }
+
+ /* Firmware */
+ ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, FW_ADDR, fw->data, fw->size);
+ if (ret) {
+ dev_err(dev, "Firmware upload failed: %d\n", ret);
+ return;
+ }
+
+ /* Boot ROM patch */
+ if (instance->modem_type->boot_rom_patch) {
+ ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, BR_ADDR, bp->data, bp->size);
+ if (ret) {
+ dev_err(dev, "Boot ROM patching failed: %d\n", ret);
+ return;
+ }
+ }
+
+ /* Signature */
+ ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, SIG_ADDR, (u8 *) signature, 4);
+ if (ret) {
+ dev_err(dev, "Signature storing failed: %d\n", ret);
+ return;
+ }
+
+ if (instance->modem_type->boot_rom_patch) {
+ val = cpu_to_le32(BR_ADDR);
+ ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, BR_STACK_ADDR, (u8 *) &val, 4);
+ }
+ else {
+ ret = cxacru_fw(usb_dev, FW_GOTO_MEM, 0x0, 0x0, FW_ADDR, NULL, 0);
+ }
+ if (ret) {
+ dev_err(dev, "Passing control to firmware failed: %d\n", ret);
+ return;
+ }
+
+ /* Delay to allow firmware to start up. */
+ msleep_interruptible(1000);
+
+ usb_clear_halt(usb_dev, usb_sndbulkpipe(usb_dev, CXACRU_EP_CMD));
+ usb_clear_halt(usb_dev, usb_rcvbulkpipe(usb_dev, CXACRU_EP_CMD));
+ usb_clear_halt(usb_dev, usb_sndbulkpipe(usb_dev, CXACRU_EP_DATA));
+ usb_clear_halt(usb_dev, usb_rcvbulkpipe(usb_dev, CXACRU_EP_DATA));
+
+ ret = cxacru_cm(instance, CM_REQUEST_CARD_GET_STATUS, NULL, 0, NULL, 0);
+ if (ret < 0) {
+ dev_err(dev, "modem failed to initialize: %d\n", ret);
+ return;
+ }
+
+ /* Load config data (le32), doing one packet at a time */
+ if (cf)
+ for (off = 0; off < cf->size / 4; ) {
+ u32 buf[CMD_PACKET_SIZE / 4 - 1];
+ int i, len = min_t(int, cf->size / 4 - off, CMD_PACKET_SIZE / 4 / 2 - 1);
+ buf[0] = cpu_to_le32(len);
+ for (i = 0; i < len; i++, off++) {
+ buf[i * 2 + 1] = cpu_to_le32(off);
+ memcpy(buf + i * 2 + 2, cf->data + off * 4, 4);
+ }
+ ret = cxacru_cm(instance, CM_REQUEST_CARD_DATA_SET,
+ (u8 *) buf, len, NULL, 0);
+ if (ret < 0) {
+ dev_err(dev, "load config data failed: %d\n", ret);
+ return;
+ }
+ }
+
+ msleep_interruptible(4000);
+}
+
+static int cxacru_find_firmware(struct cxacru_data *instance,
+ char* phase, const struct firmware **fw_p)
+{
+ struct device *dev = &instance->usbatm->usb_intf->dev;
+ char buf[16];
+
+ sprintf(buf, "cxacru-%s.bin", phase);
+ dbg("cxacru_find_firmware: looking for %s", buf);
+
+ if (request_firmware(fw_p, buf, dev)) {
+ dev_dbg(dev, "no stage %s firmware found\n", phase);
+ return -ENOENT;
+ }
+
+ dev_info(dev, "found firmware %s\n", buf);
+
+ return 0;
+}
+
+static int cxacru_heavy_init(struct usbatm_data *usbatm_instance,
+ struct usb_interface *usb_intf)
+{
+ struct device *dev = &usbatm_instance->usb_intf->dev;
+ const struct firmware *fw, *bp, *cf;
+ struct cxacru_data *instance = usbatm_instance->driver_data;
+
+ int ret = cxacru_find_firmware(instance, "fw", &fw);
+ if (ret) {
+ dev_warn(dev, "firmware (cxacru-fw.bin) unavailable (hotplug misconfiguration?)\n");
+ return ret;
+ }
+
+ if (instance->modem_type->boot_rom_patch) {
+ ret = cxacru_find_firmware(instance, "bp", &bp);
+ if (ret) {
+ dev_warn(dev, "boot ROM patch (cxacru-bp.bin) unavailable (hotplug misconfiguration?)\n");
+ release_firmware(fw);
+ return ret;
+ }
+ }
+
+ if (cxacru_find_firmware(instance, "cf", &cf)) /* optional */
+ cf = NULL;
+
+ cxacru_upload_firmware(instance, fw, bp, cf);
+
+ if (cf)
+ release_firmware(cf);
+ if (instance->modem_type->boot_rom_patch)
+ release_firmware(bp);
+ release_firmware(fw);
+
+ ret = cxacru_card_status(instance);
+ if (ret)
+ dbg("modem initialisation failed");
+ else
+ dbg("done setting up the modem");
+
+ return ret;
+}
+
+static int cxacru_bind(struct usbatm_data *usbatm_instance,
+ struct usb_interface *intf, const struct usb_device_id *id,
+ int *need_heavy_init)
+{
+ struct cxacru_data *instance;
+ struct usb_device *usb_dev = interface_to_usbdev(intf);
+ int ret;
+
+ /* instance init */
+ instance = kmalloc(sizeof(*instance), GFP_KERNEL);
+ if (!instance) {
+ dbg("cxacru_bind: no memory for instance data");
+ return -ENOMEM;
+ }
+
+ memset(instance, 0, sizeof(*instance));
+
+ instance->usbatm = usbatm_instance;
+ instance->modem_type = (struct cxacru_modem_type *) id->driver_info;
+
+ instance->rcv_buf = (u8 *) __get_free_page(GFP_KERNEL);
+ if (!instance->rcv_buf) {
+ dbg("cxacru_bind: no memory for rcv_buf");
+ ret = -ENOMEM;
+ goto fail;
+ }
+ instance->snd_buf = (u8 *) __get_free_page(GFP_KERNEL);
+ if (!instance->snd_buf) {
+ dbg("cxacru_bind: no memory for snd_buf");
+ ret = -ENOMEM;
+ goto fail;
+ }
+ instance->rcv_urb = usb_alloc_urb(0, GFP_KERNEL);
+ if (!instance->rcv_urb) {
+ dbg("cxacru_bind: no memory for rcv_urb");
+ ret = -ENOMEM;
+ goto fail;
+ }
+ instance->snd_urb = usb_alloc_urb(0, GFP_KERNEL);
+ if (!instance->snd_urb) {
+ dbg("cxacru_bind: no memory for snd_urb");
+ ret = -ENOMEM;
+ goto fail;
+ }
+
+ usb_fill_int_urb(instance->rcv_urb,
+ usb_dev, usb_rcvintpipe(usb_dev, CXACRU_EP_CMD),
+ instance->rcv_buf, PAGE_SIZE,
+ cxacru_blocking_completion, &instance->rcv_done, 1);
+ instance->rcv_urb->transfer_flags |= URB_ASYNC_UNLINK;
+
+ usb_fill_int_urb(instance->snd_urb,
+ usb_dev, usb_sndintpipe(usb_dev, CXACRU_EP_CMD),
+ instance->snd_buf, PAGE_SIZE,
+ cxacru_blocking_completion, &instance->snd_done, 4);
+ instance->snd_urb->transfer_flags |= URB_ASYNC_UNLINK;
+
+ init_MUTEX(&instance->cm_serialize);
+
+ INIT_WORK(&instance->poll_work, (void *)cxacru_poll_status, instance);
+
+ usbatm_instance->driver_data = instance;
+
+ *need_heavy_init = cxacru_card_status(instance);
+
+ return 0;
+
+ fail:
+ free_page((unsigned long) instance->snd_buf);
+ free_page((unsigned long) instance->rcv_buf);
+ usb_free_urb(instance->snd_urb);
+ usb_free_urb(instance->rcv_urb);
+ kfree(instance);
+
+ return ret;
+}
+
+static void cxacru_unbind(struct usbatm_data *usbatm_instance,
+ struct usb_interface *intf)
+{
+ struct cxacru_data *instance = usbatm_instance->driver_data;
+
+ dbg("cxacru_unbind entered");
+
+ if (!instance) {
+ dbg("cxacru_unbind: NULL instance!");
+ return;
+ }
+
+ while (!cancel_delayed_work(&instance->poll_work))
+ flush_scheduled_work();
+
+ usb_kill_urb(instance->snd_urb);
+ usb_kill_urb(instance->rcv_urb);
+ usb_free_urb(instance->snd_urb);
+ usb_free_urb(instance->rcv_urb);
+
+ free_page((unsigned long) instance->snd_buf);
+ free_page((unsigned long) instance->rcv_buf);
+ kfree(instance);
+
+ usbatm_instance->driver_data = NULL;
+}
+
+static const struct cxacru_modem_type cxacru_cafe = {
+ .pll_f_clk = 0x02d874df,
+ .pll_b_clk = 0x0196a51a,
+ .boot_rom_patch = 1,
+};
+
+static const struct cxacru_modem_type cxacru_cb00 = {
+ .pll_f_clk = 0x5,
+ .pll_b_clk = 0x3,
+ .boot_rom_patch = 0,
+};
+
+static const struct usb_device_id cxacru_usb_ids[] = {
+ { /* V = Conexant P = ADSL modem (Euphrates project) */
+ USB_DEVICE(0x0572, 0xcafe), .driver_info = (unsigned long) &cxacru_cafe
+ },
+ { /* V = Conexant P = ADSL modem (Hasbani project) */
+ USB_DEVICE(0x0572, 0xcb00), .driver_info = (unsigned long) &cxacru_cb00
+ },
+ { /* V = Conexant P = ADSL modem */
+ USB_DEVICE(0x0572, 0xcb01), .driver_info = (unsigned long) &cxacru_cb00
+ },
+ { /* V = Conexant P = ADSL modem */
+ USB_DEVICE(0x0572, 0xcb06), .driver_info = (unsigned long) &cxacru_cb00
+ },
+ { /* V = Olitec P = ADSL modem version 2 */
+ USB_DEVICE(0x08e3, 0x0100), .driver_info = (unsigned long) &cxacru_cafe
+ },
+ { /* V = Olitec P = ADSL modem version 3 */
+ USB_DEVICE(0x08e3, 0x0102), .driver_info = (unsigned long) &cxacru_cb00
+ },
+ { /* V = Trust/Amigo Technology Co. P = AMX-CA86U */
+ USB_DEVICE(0x0eb0, 0x3457), .driver_info = (unsigned long) &cxacru_cafe
+ },
+ { /* V = Zoom P = 5510 */
+ USB_DEVICE(0x1803, 0x5510), .driver_info = (unsigned long) &cxacru_cb00
+ },
+ { /* V = Draytek P = Vigor 318 */
+ USB_DEVICE(0x0675, 0x0200), .driver_info = (unsigned long) &cxacru_cb00
+ },
+ { /* V = Zyxel P = 630-C1 aka OMNI ADSL USB (Annex A) */
+ USB_DEVICE(0x0586, 0x330a), .driver_info = (unsigned long) &cxacru_cb00
+ },
+ { /* V = Zyxel P = 630-C3 aka OMNI ADSL USB (Annex B) */
+ USB_DEVICE(0x0586, 0x330b), .driver_info = (unsigned long) &cxacru_cb00
+ },
+ { /* V = Aethra P = Starmodem UM1020 */
+ USB_DEVICE(0x0659, 0x0020), .driver_info = (unsigned long) &cxacru_cb00
+ },
+ { /* V = Aztech Systems P = ? AKA Pirelli AUA-010 */
+ USB_DEVICE(0x0509, 0x0812), .driver_info = (unsigned long) &cxacru_cb00
+ },
+ { /* V = Netopia P = Cayman 3341(Annex A)/3351(Annex B) */
+ USB_DEVICE(0x100d, 0xcb01), .driver_info = (unsigned long) &cxacru_cb00
+ },
+ { /* V = Netopia P = Cayman 3342(Annex A)/3352(Annex B) */
+ USB_DEVICE(0x100d, 0x3342), .driver_info = (unsigned long) &cxacru_cb00
+ },
+ {}
+};
+
+MODULE_DEVICE_TABLE(usb, cxacru_usb_ids);
+
+static struct usbatm_driver cxacru_driver = {
+ .owner = THIS_MODULE,
+ .driver_name = cxacru_driver_name,
+ .bind = cxacru_bind,
+ .heavy_init = cxacru_heavy_init,
+ .unbind = cxacru_unbind,
+ .atm_start = cxacru_atm_start,
+ .in = CXACRU_EP_DATA,
+ .out = CXACRU_EP_DATA,
+ .rx_padding = 3,
+ .tx_padding = 11,
+};
+
+static int cxacru_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
+{
+ return usbatm_usb_probe(intf, id, &cxacru_driver);
+}
+
+static struct usb_driver cxacru_usb_driver = {
+ .owner = THIS_MODULE,
+ .name = cxacru_driver_name,
+ .probe = cxacru_usb_probe,
+ .disconnect = usbatm_usb_disconnect,
+ .id_table = cxacru_usb_ids
+};
+
+static int __init cxacru_init(void)
+{
+ return usb_register(&cxacru_usb_driver);
+}
+
+static void __exit cxacru_cleanup(void)
+{
+ usb_deregister(&cxacru_usb_driver);
+}
+
+module_init(cxacru_init);
+module_exit(cxacru_cleanup);
+
+MODULE_AUTHOR(DRIVER_AUTHOR);
+MODULE_DESCRIPTION(DRIVER_DESC);
+MODULE_LICENSE("GPL");
+MODULE_VERSION(DRIVER_VERSION);
]
|
| 245/2 |
2026/07/31 07:53 |
llm |
fixes-finder |
0m
Model:
Tokens:
input: 21980
output: 54
thoughts: 1405
Thoughts: **Analyzing the Introduction of `cxacru_cm` and Identifying a Potential Issue**
Alright, let's break this down. The code in `1b0e614652344a2d39eb336f3dc07651782883bf` introduces the `cxacru_cm` function, which is, essentially, a command and control mechanism via USB. The initial thought is to check if the bug I'm interested in was present right from this first version. Seems logical.
Looking at the code, it's pretty straightforward, but I need to make sure the flow is correct. We have `usb_submit_urb` calls for both sending and receiving, handled with completions. The key area is the error handling. If `usb_submit_urb` fails for the *send* URB (`instance->snd_urb`), it jumps to the `fail` label. This is where things get interesting. I spot it: it `up(&instance->cm_serialize)` unlocks the mutex, but it doesn't cancel or otherwise handle the *receive* URB (`instance->rcv_urb`) that might still be pending. This is a potential race condition and clearly a bug. The receiving URB could still be running after the unlock.
This confirms the bug was indeed introduced in `1b0e614652344a2d39eb336f3dc07651782883bf`, the initial commit. Just to be absolutely sure, I'll quickly check for any subsequent commits that might have tweaked this logic and inadvertently introduced or exacerbated the problem. But, I don't see any later modifications. This particular code is a one-shot deal.
Yep, the commit hash is correct, `1b0e614652344a2d39eb336f3dc07651782883bf`. I can confidently conclude that the bug I'm looking for *was* introduced by that commit. Time to report this and figure out a fix.
|
| 246/2 |
2026/07/31 07:53 |
tool |
set-results |
0m
Args: map[FixesHash:1b0e614652344a2d39eb336f3dc07651782883bf]
Results: map[FixesHash:1b0e614652344a2d39eb336f3dc07651782883bf]
|
| 247/1 |
2026/07/31 07:53 |
action |
format-fixes |
0m
Results: map[Fixes:map[AuthorEmail:duncan.sands@math.u-psud.fr AuthorName:Duncan Sands Hash:1b0e614652344a2d39eb336f3dc07651782883bf Title:[PATCH] USB ATM: driver for the Conexant AccessRunner chipset cxacru]]
|
| 248/1 |
2026/07/31 07:53 |
action |
get-maintainers |
0m
Results: map[Recipients:[map[Email:3chas3@gmail.com Name:Chas Williams To:true] map[Email:accessrunner-general@lists.sourceforge.net Name: To:true] map[Email:gregkh@linuxfoundation.org Name:Greg Kroah-Hartman To:true] map[Email:linux-atm-general@lists.sourceforge.net Name: To:true] map[Email:linux-kernel@vger.kernel.org Name: To:false] map[Email:linux-usb@vger.kernel.org Name: To:true] map[Email:netdev@vger.kernel.org Name: To:true] map[Email:duncan.sands@math.u-psud.fr Name:Duncan Sands To:true]]]
|
| 249/1 |
2026/07/31 07:53 |
action |
get-recent-commits |
0m
Results: map[RecentCommits:Convert 'alloc_obj' family to use the new default GFP_KERNEL argument
treewide: Replace kmalloc with kmalloc_obj for non-scalar types
usb: atm: cxacru: Merge cxacru_upload_firmware() into cxacru_heavy_init()
treewide, timers: Rename from_timer() to timer_container_of()
treewide, timers: Rename destroy_timer_on_stack() as timer_destroy_on_stack()
treewide: Switch/rename to timer_delete[_sync]()
usb: atm: cxacru: fix a flaw in existing endpoint checks
move asm/unaligned.h to linux/unaligned.h
usb: atm: cxacru: fix endpoint checking in cxacru_bind()
usb: atm: cxacru: Fix typo in comment
drivers: usb: atm: use atm_info() instead of atm_printk(KERN_INFO ...
drivers: usb: atm: reduce noise
usb: atm: don't use snprintf() for sysfs attrs
usb: Use fallthrough pseudo-keyword
USB: atm: cxacru: convert to use dev_groups
USB: atm: fix up some remaining DEVICE_ATTR() usage
usb: usbatm: Convert timers to use timer_setup()
USB: atm: Remove redundant license text
USB: add SPDX identifiers to all remaining files in drivers/usb/
usb: atm: cxacru: mark expected switch fall-throughs
]
|
| 250/1 |
2026/07/31 07:53 |
agent |
description-generator |
0m
Model:
Instruction:
You are an experienced Linux kernel developer tasked with writing a commit description for
a kernel bug fixing commit. The description should start with a one-line summary,
and then include description of the bug being fixed, and how it's fixed by the provided patch.
The one-line summary should describe the change being made, rather than mention the tool that
detected the bug.
The description must not contain lines starting with '#' because they will dropped by git as comments.
The description must not contain lines starting with '--' or '---' (including inline code diffs)
because they may confuse git/patch utilities.
Your final reply should contain only the text of the commit description.
The one-line summary must be not longer than 72 characters.
IMPORTANT: Do not wrap lines manually (e.g., at 80 characters); we will reformat the text
automatically, so keep paragraphs as single lines without newlines.
Generally try to phrase the description without mentioning syzkaller
(avoid phrases like "the bug was triggered by syzkaller" or "the bug was triggered by fuzzer", etc).
How the bug was triggered is generally an irrelevant detail.
Any bug triggered by a fuzzer can also be triggered by a malicious user, or a buggy program.
If the crash is reported by a sanitizer (e.g., KASAN, KMSAN, lockdep), include the relevant
parts of the sanitizer output to illustrate the problem. Exclude less relevant sections,
as the stack trace can be very long. Describe the execution path that leads to the manifestation
of the kernel bug.
If the patch removes the WARN_ON macro, refer to the fact that WARN_ON
must not be used for conditions that can legitimately happen, and that pr_err
should be used instead if necessary.
Don't assume that panic_on_warn is set, and that WARNINGs are fatal.
While panic_on_warn may be set when the bug was reproduced, it's generally not set on production systems.
Prefer calling several tools at the same time to save round-trips.
Prompt:
The crash that corresponds to the bug is:
cxacru 1-1:1.0: send of cm 0x84 failed (-104)
ATM dev 0: cxacru_atm_start: CHIP_ADSL_LINE_START returned -104
------------[ cut here ]------------
URB ffff88812658d200 submitted while active
WARNING: drivers/usb/core/urb.c:379 at usb_submit_urb+0x79/0x18b0 drivers/usb/core/urb.c:379, CPU#1: kworker/1:1/5258
Modules linked in:
CPU: 1 UID: 0 PID: 5258 Comm: kworker/1:1 Not tainted syzkaller #1 PREEMPT(lazy)
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
Workqueue: usb_hub_wq hub_event
RIP: 0010:usb_submit_urb+0x7c/0x18b0 drivers/usb/core/urb.c:379
Code: 4c 89 f0 48 c1 e8 03 80 3c 28 00 74 08 4c 89 f7 e8 c9 ab f6 fc 49 83 3e 00 74 40 e8 9e 5e 91 fc 48 8d 3d 47 b1 aa 05 48 89 de <67> 48 0f b9 3a b8 f0 ff ff ff eb 11 e8 83 5e 91 fc eb 05 e8 7c 5e
RSP: 0018:ffffc90002476878 EFLAGS: 00010293
RAX: ffffffff84f3e532 RBX: ffff88812658d200 RCX: ffff88812fb42440
RDX: 0000000000000000 RSI: ffff88812658d200 RDI: ffffffff8a9e9680
RBP: dffffc0000000000 R08: 0000000000000002 R09: 0000000000000000
R10: dffffc0000000000 R11: fffffbfff152f477 R12: 0000000000000040
R13: 0000000000000000 R14: ffff88812658d208 R15: 0000000000000cc0
FS: 0000000000000000(0000) GS:ffff8882a9042000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f7be0a0cfe0 CR3: 000000011d54e000 CR4: 0000000000350ef0
Call Trace:
<TASK>
cxacru_cm+0x21a/0xf10 drivers/usb/atm/cxacru.c:631
cxacru_cm_get_array drivers/usb/atm/cxacru.c:722 [inline]
cxacru_poll_status+0x178/0x1110 drivers/usb/atm/cxacru.c:828
cxacru_atm_start+0x185/0x360 drivers/usb/atm/cxacru.c:814
usbatm_atm_init+0x144/0x3a0 drivers/usb/atm/usbatm.c:927
usbatm_usb_probe+0x15cb/0x1db0 drivers/usb/atm/usbatm.c:1178
cxacru_usb_probe+0x17f/0x220 drivers/usb/atm/cxacru.c:1370
usb_probe_interface+0x653/0xc60 drivers/usb/core/driver.c:396
call_driver_probe drivers/base/dd.c:-1 [inline]
really_probe+0x254/0xae0 drivers/base/dd.c:706
__driver_probe_device+0x1e8/0x360 drivers/base/dd.c:868
driver_probe_device+0x4f/0x240 drivers/base/dd.c:898
__device_attach_driver+0x270/0x410 drivers/base/dd.c:1026
bus_for_each_drv+0x258/0x2f0 drivers/base/bus.c:500
__device_attach+0x2c4/0x450 drivers/base/dd.c:1098
device_initial_probe+0xa1/0xd0 drivers/base/dd.c:1153
bus_probe_device+0x12a/0x220 drivers/base/bus.c:620
device_add+0x7d7/0xb80 drivers/base/core.c:3772
usb_set_configuration+0x1ad8/0x2180 drivers/usb/core/message.c:2268
usb_generic_driver_probe+0x8d/0x150 drivers/usb/core/generic.c:250
usb_probe_device+0x1c3/0x3b0 drivers/usb/core/driver.c:291
call_driver_probe drivers/base/dd.c:-1 [inline]
really_probe+0x254/0xae0 drivers/base/dd.c:706
__driver_probe_device+0x1e8/0x360 drivers/base/dd.c:868
driver_probe_device+0x4f/0x240 drivers/base/dd.c:898
__device_attach_driver+0x270/0x410 drivers/base/dd.c:1026
bus_for_each_drv+0x258/0x2f0 drivers/base/bus.c:500
__device_attach+0x2c4/0x450 drivers/base/dd.c:1098
device_initial_probe+0xa1/0xd0 drivers/base/dd.c:1153
bus_probe_device+0x12a/0x220 drivers/base/bus.c:620
device_add+0x7d7/0xb80 drivers/base/core.c:3772
usb_new_device+0x99d/0x1620 drivers/usb/core/hub.c:2695
hub_port_connect drivers/usb/core/hub.c:5567 [inline]
hub_port_connect_change drivers/usb/core/hub.c:5707 [inline]
port_event drivers/usb/core/hub.c:5871 [inline]
hub_event+0x28e8/0x4d30 drivers/usb/core/hub.c:5953
process_one_work kernel/workqueue.c:3322 [inline]
process_scheduled_works+0xa8e/0x14e0 kernel/workqueue.c:3405
worker_thread+0x92d/0xe10 kernel/workqueue.c:3486
kthread+0x388/0x470 kernel/kthread.c:436
ret_from_fork+0x491/0xad0 arch/x86/kernel/process.c:158
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
</TASK>
----------------
Code disassembly (best guess):
0: 4c 89 f0 mov %r14,%rax
3: 48 c1 e8 03 shr $0x3,%rax
7: 80 3c 28 00 cmpb $0x0,(%rax,%rbp,1)
b: 74 08 je 0x15
d: 4c 89 f7 mov %r14,%rdi
10: e8 c9 ab f6 fc call 0xfcf6abde
15: 49 83 3e 00 cmpq $0x0,(%r14)
19: 74 40 je 0x5b
1b: e8 9e 5e 91 fc call 0xfc915ebe
20: 48 8d 3d 47 b1 aa 05 lea 0x5aab147(%rip),%rdi # 0x5aab16e
27: 48 89 de mov %rbx,%rsi
* 2a: 67 48 0f b9 3a ud1 (%edx),%rdi <-- trapping instruction
2f: b8 f0 ff ff ff mov $0xfffffff0,%eax
34: eb 11 jmp 0x47
36: e8 83 5e 91 fc call 0xfc915ebe
3b: eb 05 jmp 0x42
3d: e8 .byte 0xe8
3e: 7c 5e jl 0x9e
The explanation of the root cause of the bug is:
The root cause of this bug is that `cxacru_cm()` leaves `rcv_urb` active if it encounters an error while submitting or waiting for `snd_urb`.
Here is the exact sequence of events that leads to the crash:
1. `cxacru_atm_start()` calls `cxacru_cm()` to send the `CM_REQUEST_CHIP_ADSL_LINE_START` (`0x84`) command.
2. Inside `cxacru_cm()`, `rcv_urb` is successfully submitted first (line 631).
3. Then, `snd_urb` is submitted and `cxacru_cm()` waits for its completion via `cxacru_start_wait_urb()` (line 657).
4. In the syzkaller reproducer, the USB device behaves unexpectedly (e.g., endpoint stall or disconnect), causing `snd_urb` to complete with an error status of `-104` (`-ECONNRESET`).
5. `cxacru_start_wait_urb()` returns this `-104` error, which prompts `cxacru_cm()` to print `"send of cm 0x84 failed (-104)"` and jump to the `fail:` label (line 661).
6. At the `fail:` label, `cxacru_cm()` simply unlocks the mutex and returns the error, **leaving `rcv_urb` still active and pending**.
7. Back in `cxacru_atm_start()`, the error is printed (`"CHIP_ADSL_LINE_START returned -104"`) but ignored, and the driver proceeds to start status polling by calling `cxacru_poll_status()`.
8. `cxacru_poll_status()` immediately calls `cxacru_cm_get_array()`, which invokes `cxacru_cm()` again.
9. `cxacru_cm()` attempts to submit `rcv_urb` again, but since it was never unlinked or waited for in the previous failed call, it is still active. This triggers the `URB ... submitted while active` warning in `usb_submit_urb()`.
### Fix
To fix this bug, we need to ensure that `rcv_urb` is properly killed if `cxacru_cm()` aborts early. We can safely call `usb_kill_urb()` on `rcv_urb` in the error path. `usb_kill_urb()` is safe to call even if the URB is not active (e.g., if it failed to submit in the first place, or if it already completed), so it can be called unconditionally on error.
```c
--- a/drivers/usb/atm/cxacru.c
+++ b/drivers/usb/atm/cxacru.c
@@ -700,6 +700,8 @@ static int cxacru_cm(struct cxacru_data *instance, enum cxacru_cm_request cm,
ret = offd;
usb_dbg(instance->usbatm, "cm %#x\n", cm);
fail:
+ if (ret < 0)
+ usb_kill_urb(instance->rcv_urb);
mutex_unlock(&instance->cm_serialize);
err:
return ret;
```
The diff of the bug fix is:
diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
index f1900c567..429ac20a8 100644
--- a/drivers/usb/atm/cxacru.c
+++ b/drivers/usb/atm/cxacru.c
@@ -700,6 +700,8 @@ static int cxacru_cm(struct cxacru_data *instance, enum cxacru_cm_request cm,
ret = offd;
usb_dbg(instance->usbatm, "cm %#x\n", cm);
fail:
+ if (ret < 0)
+ usb_kill_urb(instance->rcv_urb);
mutex_unlock(&instance->cm_serialize);
err:
return ret;
Additional description of the patch:
The root cause of this bug is that `cxacru_cm()` leaves `rcv_urb` active if it encounters an error while submitting or waiting for `snd_urb`.
Here is the exact sequence of events that leads to the crash:
1. `cxacru_atm_start()` calls `cxacru_cm()` to send the `CM_REQUEST_CHIP_ADSL_LINE_START` command.
2. Inside `cxacru_cm()`, `rcv_urb` is successfully submitted first.
3. Then, `snd_urb` is submitted and `cxacru_cm()` waits for its completion via `cxacru_start_wait_urb()`.
4. If the USB device behaves unexpectedly, `snd_urb` completes with an error status (e.g., `-104`).
5. `cxacru_start_wait_urb()` returns this error, which prompts `cxacru_cm()` to jump to the `fail:` label.
6. At the `fail:` label, `cxacru_cm()` simply unlocks the mutex and returns the error, leaving `rcv_urb` still active and pending.
7. Back in `cxacru_atm_start()`, the error is ignored, and the driver proceeds to start status polling by calling `cxacru_poll_status()`.
8. `cxacru_poll_status()` immediately calls `cxacru_cm_get_array()`, which invokes `cxacru_cm()` again.
9. `cxacru_cm()` attempts to submit `rcv_urb` again, but since it was never unlinked or waited for in the previous failed call, it is still active. This triggers the `URB ... submitted while active` warning in `usb_submit_urb()`.
To fix this bug, we need to ensure that `rcv_urb` is properly killed if `cxacru_cm()` aborts early. We can safely call `usb_kill_urb()` on `rcv_urb` in the error path. `usb_kill_urb()` is safe to call even if the URB is not active (e.g., if it failed to submit in the first place, or if it already completed), so it can be called unconditionally on error.
Note that we don't need to do the same for `snd_urb` because `cxacru_start_wait_urb()` uses `wait_for_completion()` which is uninterruptible, meaning it will always wait until the URB completes (either successfully, with an error, or by timing out and being unlinked). Thus, `snd_urb` is never left active when `cxacru_start_wait_urb()` returns.
I have applied the fix using the `codeeditor` tool. The patch adds `usb_kill_urb(instance->rcv_urb)` in the `fail:` path of `cxacru_cm()` if `ret < 0`. This guarantees that subsequent calls to `cxacru_cm()` will start with a clean state, preventing the `URB submitted while active` warning.
Here are summaries of recent commits that touched the same files.
Format the summary line consistently with these, look how prefixes
are specified, letter capitalization, style, etc.
Convert 'alloc_obj' family to use the new default GFP_KERNEL argument
treewide: Replace kmalloc with kmalloc_obj for non-scalar types
usb: atm: cxacru: Merge cxacru_upload_firmware() into cxacru_heavy_init()
treewide, timers: Rename from_timer() to timer_container_of()
treewide, timers: Rename destroy_timer_on_stack() as timer_destroy_on_stack()
treewide: Switch/rename to timer_delete[_sync]()
usb: atm: cxacru: fix a flaw in existing endpoint checks
move asm/unaligned.h to linux/unaligned.h
usb: atm: cxacru: fix endpoint checking in cxacru_bind()
usb: atm: cxacru: Fix typo in comment
drivers: usb: atm: use atm_info() instead of atm_printk(KERN_INFO ...
drivers: usb: atm: reduce noise
usb: atm: don't use snprintf() for sysfs attrs
usb: Use fallthrough pseudo-keyword
USB: atm: cxacru: convert to use dev_groups
USB: atm: fix up some remaining DEVICE_ATTR() usage
usb: usbatm: Convert timers to use timer_setup()
USB: atm: Remove redundant license text
USB: add SPDX identifiers to all remaining files in drivers/usb/
usb: atm: cxacru: mark expected switch fall-throughs
Reply: usb: atm: cxacru: properly kill rcv_urb on error in cxacru_cm()
If cxacru_cm() encounters an error while submitting or waiting for snd_urb,
it aborts and returns the error without killing the already submitted
rcv_urb. This leaves the rcv_urb active.
When this happens during initialization (e.g., in cxacru_atm_start()), the
driver may ignore the error and proceed to call cxacru_poll_status(), which
invokes cxacru_cm() again. Attempting to submit the still-active rcv_urb
triggers a warning in usb_submit_urb():
cxacru 1-1:1.0: send of cm 0x84 failed (-104)
ATM dev 0: cxacru_atm_start: CHIP_ADSL_LINE_START returned -104
------------[ cut here ]------------
URB ffff88812658d200 submitted while active
WARNING: drivers/usb/core/urb.c:379 at usb_submit_urb+0x79/0x18b0
drivers/usb/core/urb.c:379
...
Call Trace:
<TASK>
cxacru_cm+0x21a/0xf10 drivers/usb/atm/cxacru.c:631
cxacru_cm_get_array drivers/usb/atm/cxacru.c:722 [inline]
cxacru_poll_status+0x178/0x1110 drivers/usb/atm/cxacru.c:828
cxacru_atm_start+0x185/0x360 drivers/usb/atm/cxacru.c:814
usbatm_atm_init+0x144/0x3a0 drivers/usb/atm/usbatm.c:927
usbatm_usb_probe+0x15cb/0x1db0 drivers/usb/atm/usbatm.c:1178
cxacru_usb_probe+0x17f/0x220 drivers/usb/atm/cxacru.c:1370
...
To fix this, ensure that rcv_urb is properly killed if cxacru_cm() aborts
early. We can safely call usb_kill_urb() on rcv_urb in the error path, as
it is safe to call even if the URB is not active (e.g., if it failed to
submit in the first place, or if it already completed).
|
| 251/2 |
2026/07/31 07:53 |
llm |
description-generator |
0m
Model:
Tokens:
input: 8633
output: 598
thoughts: 2593
Thoughts: **Commit Summary: Resolving an URB Submission Issue in cxacru_cm()**
Okay, so I've got a handle on this `cxacru.c` bug. The problem is a "URB submitted while active" warning in `usb_submit_urb()`. Digging in, it appears `cxacru_cm()` has a flaw. When it encounters an error while either submitting or waiting for the `snd_urb`, it bails out via the `fail:` label. The critical oversight is that it *doesn't* unlink or kill the already submitted `rcv_urb`.
The sequence is: `cxacru_atm_start()` calls `cxacru_cm()`. Inside `cxacru_cm()`, `rcv_urb` is submitted, then `snd_urb` is sent and the code waits. If the USB device throws an error (like a `-104`), `cxacru_start_wait_urb()` returns this error and we hit the `fail:` label in `cxacru_cm()`. The function just unlocks the mutex and returns. This leaves `rcv_urb` still active! Later, `cxacru_poll_status()` calls `cxacru_cm()` again, and the driver tries to submit the `rcv_urb` *again*, triggering that warning, because it's still marked as active from the previous failed call. It's a subtle but definite race condition stemming from a failed early exit from the function.
Here's the snippet from the warning in the log:
```
cxacru 1-1:1.0: send of cm 0x84 failed (-104)
ATM dev 0: cxacru_atm_start: CHIP_ADSL_LINE_START returned -104
------------[ cut here ]------------
URB ffff88812658d200 submitted while active
WARNING: drivers/usb/core/urb.c:379 at usb_submit_urb+0x79/0x18b0 drivers/usb/core/urb.c:379
...
Call Trace:
cxacru_cm+0x21a/0xf10 drivers/usb/atm/cxacru.c:631
cxacru_cm_get_array drivers/usb/atm/cxacru.c:722 [inline]
cxacru_poll_status+0x178/0x1110 drivers/usb/atm/cxacru.c:828
cxacru_atm_start+0x185/0x360 drivers/usb/atm/cxacru.c:814
usbatm_atm_init+0x144/0x3a0 drivers/usb/atm/usbatm.c:927
usbatm_usb_probe+0x15cb/0x1db0 drivers/usb/atm/usbatm.c:1178
cxacru_usb_probe+0x17f/0x220 drivers/usb/atm/cxacru.c:1370
...
```
The fix is simple: I'll add `usb_kill_urb(instance->rcv_urb)` to the `fail:` path in `cxacru_cm()`. This way, if we encounter an error, we make sure the `rcv_urb` is unlinked and stopped. It's safe to call `usb_kill_urb()` even if the URB isn't actively submitting; if the submission failed or it has already completed, it's a no-op.
|