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

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>

authored by

Johan Hovold and committed by
Greg Kroah-Hartman
d6124b40 afe4155c

+15 -3
+13 -3
drivers/uwb/lc-rc.c
··· 56 56 struct uwb_rc *rc = NULL; 57 57 58 58 dev = class_find_device(&uwb_rc_class, NULL, &index, uwb_rc_index_match); 59 - if (dev) 59 + if (dev) { 60 60 rc = dev_get_drvdata(dev); 61 + put_device(dev); 62 + } 63 + 61 64 return rc; 62 65 } 63 66 ··· 470 467 if (dev) { 471 468 rc = dev_get_drvdata(dev); 472 469 __uwb_rc_get(rc); 470 + put_device(dev); 473 471 } 472 + 474 473 return rc; 475 474 } 476 475 EXPORT_SYMBOL_GPL(__uwb_rc_try_get); ··· 525 520 526 521 dev = class_find_device(&uwb_rc_class, NULL, grandpa_dev, 527 522 find_rc_grandpa); 528 - if (dev) 523 + if (dev) { 529 524 rc = dev_get_drvdata(dev); 525 + put_device(dev); 526 + } 527 + 530 528 return rc; 531 529 } 532 530 EXPORT_SYMBOL_GPL(uwb_rc_get_by_grandpa); ··· 561 553 struct uwb_rc *rc = NULL; 562 554 563 555 dev = class_find_device(&uwb_rc_class, NULL, addr, find_rc_dev); 564 - if (dev) 556 + if (dev) { 565 557 rc = dev_get_drvdata(dev); 558 + put_device(dev); 559 + } 566 560 567 561 return rc; 568 562 }
+2
drivers/uwb/pal.c
··· 97 97 98 98 dev = class_find_device(&uwb_rc_class, NULL, target_rc, find_rc); 99 99 100 + put_device(dev); 101 + 100 102 return (dev != NULL); 101 103 } 102 104