aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/rfcomm/tty.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/bluetooth/rfcomm/tty.c')
-rw-r--r--net/bluetooth/rfcomm/tty.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
index 111c6c858247..d030c69cb5a3 100644
--- a/net/bluetooth/rfcomm/tty.c
+++ b/net/bluetooth/rfcomm/tty.c
@@ -298,18 +298,15 @@ static int rfcomm_dev_add(struct rfcomm_dev_req *req, struct rfcomm_dlc *dlc)
298out: 298out:
299 write_unlock_bh(&rfcomm_dev_lock); 299 write_unlock_bh(&rfcomm_dev_lock);
300 300
301 if (err < 0) { 301 if (err < 0)
302 kfree(dev); 302 goto free;
303 return err;
304 }
305 303
306 dev->tty_dev = tty_register_device(rfcomm_tty_driver, dev->id, NULL); 304 dev->tty_dev = tty_register_device(rfcomm_tty_driver, dev->id, NULL);
307 305
308 if (IS_ERR(dev->tty_dev)) { 306 if (IS_ERR(dev->tty_dev)) {
309 err = PTR_ERR(dev->tty_dev); 307 err = PTR_ERR(dev->tty_dev);
310 list_del(&dev->list); 308 list_del(&dev->list);
311 kfree(dev); 309 goto free;
312 return err;
313 } 310 }
314 311
315 dev_set_drvdata(dev->tty_dev, dev); 312 dev_set_drvdata(dev->tty_dev, dev);
@@ -321,6 +318,10 @@ out:
321 BT_ERR("Failed to create channel attribute"); 318 BT_ERR("Failed to create channel attribute");
322 319
323 return dev->id; 320 return dev->id;
321
322free:
323 kfree(dev);
324 return err;
324} 325}
325 326
326static void rfcomm_dev_del(struct rfcomm_dev *dev) 327static void rfcomm_dev_del(struct rfcomm_dev *dev)