Skip to content
This repository was archived by the owner on Oct 31, 2024. It is now read-only.

Commit ccbf09d

Browse files
Ma Kegregkh
Ma Ke
authored andcommitted
pps: add an error check in parport_attach
commit 62c5a01 upstream. In parport_attach, the return value of ida_alloc is unchecked, witch leads to the use of an invalid index value. To address this issue, index should be checked. When the index value is abnormal, the device should be freed. Found by code review, compile tested only. Cc: stable@vger.kernel.org Fixes: fb56d97 ("pps: client: use new parport device model") Signed-off-by: Ma Ke <make24@iscas.ac.cn> Acked-by: Rodolfo Giometti <giometti@enneenne.com> Link: https://lore.kernel.org/r/20240828131814.3034338-1-make24@iscas.ac.cn Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent b59ba1c commit ccbf09d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/pps/clients/pps_parport.c

+6-2
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,9 @@ static void parport_attach(struct parport *port)
149149
}
150150

151151
index = ida_alloc(&pps_client_index, GFP_KERNEL);
152+
if (index < 0)
153+
goto err_free_device;
154+
152155
memset(&pps_client_cb, 0, sizeof(pps_client_cb));
153156
pps_client_cb.private = device;
154157
pps_client_cb.irq_func = parport_irq;
@@ -159,7 +162,7 @@ static void parport_attach(struct parport *port)
159162
index);
160163
if (!device->pardev) {
161164
pr_err("couldn't register with %s\n", port->name);
162-
goto err_free;
165+
goto err_free_ida;
163166
}
164167

165168
if (parport_claim_or_block(device->pardev) < 0) {
@@ -187,8 +190,9 @@ static void parport_attach(struct parport *port)
187190
parport_release(device->pardev);
188191
err_unregister_dev:
189192
parport_unregister_device(device->pardev);
190-
err_free:
193+
err_free_ida:
191194
ida_free(&pps_client_index, index);
195+
err_free_device:
192196
kfree(device);
193197
}
194198

0 commit comments

Comments
 (0)