aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Hovold <johan@kernel.org>2016-11-01 07:13:31 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-11-01 11:04:04 -0400
commitd6124b409ca33c100170ffde51cd8dff761454a1 (patch)
tree206aabea49fc3f514eb2ac0f70945fc582a50214
parentafe4155ce940d0c2a8fa3da5a29ea46f98052a73 (diff)
uwb: fix device reference leaks
This subsystem consistently fails to drop the device reference taken by class_find_device(). Note that some of these lookup functions already take a reference to the returned data, while others claim no reference is needed (or does not seem need one). Fixes: 183b9b592a62 ("uwb: add the UWB stack (core files)") Signed-off-by: Johan Hovold <johan@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/uwb/lc-rc.c16
-rw-r--r--drivers/uwb/pal.c2
2 files changed, 15 insertions, 3 deletions
diff --git a/drivers/uwb/lc-rc.c b/drivers/uwb/lc-rc.c
index d059ad4d0dbd..97ee1b46db69 100644
--- a/drivers/uwb/lc-rc.c
+++ b/drivers/uwb/lc-rc.c
@@ -56,8 +56,11 @@ static struct uwb_rc *uwb_rc_find_by_index(int index)
56 struct uwb_rc *rc = NULL; 56 struct uwb_rc *rc = NULL;
57 57
58 dev = class_find_device(&uwb_rc_class, NULL, &index, uwb_rc_index_match); 58 dev = class_find_device(&uwb_rc_class, NULL, &index, uwb_rc_index_match);
59 if (dev) 59 if (dev) {
60 rc = dev_get_drvdata(dev); 60 rc = dev_get_drvdata(dev);
61 put_device(dev);
62 }
63
61 return rc; 64 return rc;
62} 65}
63 66
@@ -467,7 +470,9 @@ struct uwb_rc *__uwb_rc_try_get(struct uwb_rc *target_rc)
467 if (dev) { 470 if (dev) {
468 rc = dev_get_drvdata(dev); 471 rc = dev_get_drvdata(dev);
469 __uwb_rc_get(rc); 472 __uwb_rc_get(rc);
473 put_device(dev);
470 } 474 }
475
471 return rc; 476 return rc;
472} 477}
473EXPORT_SYMBOL_GPL(__uwb_rc_try_get); 478EXPORT_SYMBOL_GPL(__uwb_rc_try_get);
@@ -520,8 +525,11 @@ struct uwb_rc *uwb_rc_get_by_grandpa(const struct device *grandpa_dev)
520 525
521 dev = class_find_device(&uwb_rc_class, NULL, grandpa_dev, 526 dev = class_find_device(&uwb_rc_class, NULL, grandpa_dev,
522 find_rc_grandpa); 527 find_rc_grandpa);
523 if (dev) 528 if (dev) {
524 rc = dev_get_drvdata(dev); 529 rc = dev_get_drvdata(dev);
530 put_device(dev);
531 }
532
525 return rc; 533 return rc;
526} 534}
527EXPORT_SYMBOL_GPL(uwb_rc_get_by_grandpa); 535EXPORT_SYMBOL_GPL(uwb_rc_get_by_grandpa);
@@ -553,8 +561,10 @@ struct uwb_rc *uwb_rc_get_by_dev(const struct uwb_dev_addr *addr)
553 struct uwb_rc *rc = NULL; 561 struct uwb_rc *rc = NULL;
554 562
555 dev = class_find_device(&uwb_rc_class, NULL, addr, find_rc_dev); 563 dev = class_find_device(&uwb_rc_class, NULL, addr, find_rc_dev);
556 if (dev) 564 if (dev) {
557 rc = dev_get_drvdata(dev); 565 rc = dev_get_drvdata(dev);
566 put_device(dev);
567 }
558 568
559 return rc; 569 return rc;
560} 570}
diff --git a/drivers/uwb/pal.c b/drivers/uwb/pal.c
index c1304b8d4985..678e93741ae1 100644
--- a/drivers/uwb/pal.c
+++ b/drivers/uwb/pal.c
@@ -97,6 +97,8 @@ static bool uwb_rc_class_device_exists(struct uwb_rc *target_rc)
97 97
98 dev = class_find_device(&uwb_rc_class, NULL, target_rc, find_rc); 98 dev = class_find_device(&uwb_rc_class, NULL, target_rc, find_rc);
99 99
100 put_device(dev);
101
100 return (dev != NULL); 102 return (dev != NULL);
101} 103}
102 104