Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[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 <marcel@holtmann.org>

authored by

Marcel Holtmann and committed by
David S. Miller
df5c37ea e9c5702e

+16 -7
+8 -3
net/bluetooth/hci_sysfs.c
··· 242 242 struct hci_conn *conn = data; 243 243 int i; 244 244 245 - device_register(&conn->dev); 245 + if (device_register(&conn->dev) < 0) { 246 + BT_ERR("Failed to register connection device"); 247 + return; 248 + } 246 249 247 250 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"); 249 253 } 250 254 251 255 void hci_conn_add_sysfs(struct hci_conn *conn) ··· 316 312 return err; 317 313 318 314 for (i = 0; bt_attrs[i]; i++) 319 - device_create_file(dev, bt_attrs[i]); 315 + if (device_create_file(dev, bt_attrs[i]) < 0) 316 + BT_ERR("Failed to create device attribute"); 320 317 321 318 return 0; 322 319 }
+2 -1
net/bluetooth/l2cap.c
··· 2216 2216 goto error; 2217 2217 } 2218 2218 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"); 2220 2221 2221 2222 BT_INFO("L2CAP ver %s", VERSION); 2222 2223 BT_INFO("L2CAP socket layer initialized");
+2 -1
net/bluetooth/rfcomm/core.c
··· 2058 2058 2059 2059 kernel_thread(rfcomm_run, NULL, CLONE_KERNEL); 2060 2060 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"); 2062 2063 2063 2064 rfcomm_init_sockets(); 2064 2065
+2 -1
net/bluetooth/rfcomm/sock.c
··· 944 944 if (err < 0) 945 945 goto error; 946 946 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"); 948 949 949 950 BT_INFO("RFCOMM socket layer initialized"); 950 951
+2 -1
net/bluetooth/sco.c
··· 967 967 goto error; 968 968 } 969 969 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"); 971 972 972 973 BT_INFO("SCO (Voice Link) ver %s", VERSION); 973 974 BT_INFO("SCO socket layer initialized");