Skip to content

Commit df5c37e

Browse files
holtmannDavid S. Miller
authored andcommitted
[Bluetooth] Handle return values from driver core functions
Some return values of the driver core register and create functions are not handled and so might cause unexpected problems. Signed-off-by: Marcel Holtmann <[email protected]>
1 parent e9c5702 commit df5c37e

File tree

5 files changed

+16
-7
lines changed

5 files changed

+16
-7
lines changed

net/bluetooth/hci_sysfs.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,10 +242,14 @@ static void add_conn(void *data)
242242
struct hci_conn *conn = data;
243243
int i;
244244

245-
device_register(&conn->dev);
245+
if (device_register(&conn->dev) < 0) {
246+
BT_ERR("Failed to register connection device");
247+
return;
248+
}
246249

247250
for (i = 0; conn_attrs[i]; i++)
248-
device_create_file(&conn->dev, conn_attrs[i]);
251+
if (device_create_file(&conn->dev, conn_attrs[i]) < 0)
252+
BT_ERR("Failed to create connection attribute");
249253
}
250254

251255
void hci_conn_add_sysfs(struct hci_conn *conn)
@@ -312,7 +316,8 @@ int hci_register_sysfs(struct hci_dev *hdev)
312316
return err;
313317

314318
for (i = 0; bt_attrs[i]; i++)
315-
device_create_file(dev, bt_attrs[i]);
319+
if (device_create_file(dev, bt_attrs[i]) < 0)
320+
BT_ERR("Failed to create device attribute");
316321

317322
return 0;
318323
}

net/bluetooth/l2cap.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2216,7 +2216,8 @@ static int __init l2cap_init(void)
22162216
goto error;
22172217
}
22182218

2219-
class_create_file(bt_class, &class_attr_l2cap);
2219+
if (class_create_file(bt_class, &class_attr_l2cap) < 0)
2220+
BT_ERR("Failed to create L2CAP info file");
22202221

22212222
BT_INFO("L2CAP ver %s", VERSION);
22222223
BT_INFO("L2CAP socket layer initialized");

net/bluetooth/rfcomm/core.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2058,7 +2058,8 @@ static int __init rfcomm_init(void)
20582058

20592059
kernel_thread(rfcomm_run, NULL, CLONE_KERNEL);
20602060

2061-
class_create_file(bt_class, &class_attr_rfcomm_dlc);
2061+
if (class_create_file(bt_class, &class_attr_rfcomm_dlc) < 0)
2062+
BT_ERR("Failed to create RFCOMM info file");
20622063

20632064
rfcomm_init_sockets();
20642065

net/bluetooth/rfcomm/sock.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,8 @@ int __init rfcomm_init_sockets(void)
944944
if (err < 0)
945945
goto error;
946946

947-
class_create_file(bt_class, &class_attr_rfcomm);
947+
if (class_create_file(bt_class, &class_attr_rfcomm) < 0)
948+
BT_ERR("Failed to create RFCOMM info file");
948949

949950
BT_INFO("RFCOMM socket layer initialized");
950951

net/bluetooth/sco.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -967,7 +967,8 @@ static int __init sco_init(void)
967967
goto error;
968968
}
969969

970-
class_create_file(bt_class, &class_attr_sco);
970+
if (class_create_file(bt_class, &class_attr_sco) < 0)
971+
BT_ERR("Failed to create SCO info file");
971972

972973
BT_INFO("SCO (Voice Link) ver %s", VERSION);
973974
BT_INFO("SCO socket layer initialized");

0 commit comments

Comments
 (0)