mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 17:47:41 +02:00
block: partitions: fix of_node refcount leak in of_partition()
of_partition() calls of_node_get() on the parent device node at the
beginning of the function, storing the reference in 'partitions_np'.
This reference is leaked in two paths:
1. The compatibility check at the top of the function returns 0
without releasing partitions_np when the node exists but is not
"fixed-partitions" compatible.
2. The function returns 1 at the end after successfully processing
all partitions without releasing partitions_np.
Fix both leaks by adding of_node_put(partitions_np) on each path.
Fixes: 2e3a191e89 ("block: add support for partition table defined in OF")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
Reviewed-by: Md Haris Iqbal <haris.iqbal@linux.dev>
Link: https://patch.msgid.link/20260526102124.2283846-1-vulab@iscas.ac.cn
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
23130b3ffc
commit
148cd48731
|
|
@ -74,8 +74,10 @@ int of_partition(struct parsed_partitions *state)
|
|||
struct device_node *partitions_np = of_node_get(ddev->of_node);
|
||||
|
||||
if (!partitions_np ||
|
||||
!of_device_is_compatible(partitions_np, "fixed-partitions"))
|
||||
!of_device_is_compatible(partitions_np, "fixed-partitions")) {
|
||||
of_node_put(partitions_np);
|
||||
return 0;
|
||||
}
|
||||
|
||||
slot = 1;
|
||||
/* Validate parition offset and size */
|
||||
|
|
@ -104,5 +106,6 @@ int of_partition(struct parsed_partitions *state)
|
|||
|
||||
seq_buf_puts(&state->pp_buf, "\n");
|
||||
|
||||
of_node_put(partitions_np);
|
||||
return 1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user