Re: [PATCH] block :blk-sysfs: fix refcount imbalance on the error path

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 6/3/19 12:46 AM, Lin Yi wrote:
kobject_add takes a refcount to the object dev->kobj, but forget to
release it on the error path, lead to a memory leak.

Signed-off-by: Lin Yi <teroincn@xxxxxxx>
---
  block/blk-sysfs.c | 1 +
  1 file changed, 1 insertion(+)

diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index 75b5281..539b7cb 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -971,6 +971,7 @@ int blk_register_queue(struct gendisk *disk)
  	ret = kobject_add(&q->kobj, kobject_get(&dev->kobj), "%s", "queue");
  	if (ret < 0) {
  		blk_trace_remove_sysfs(dev);
+		kobject_put(&dev->kobj);
  		goto unlock;
  	}

Have you reviewed the other kobject_add() calls in the block layer? Are there more such calls that need to be fixed?

Additionally, please add "Fixes:" and "Cc: stable" tags.

Thanks,

Bart.



[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux