diff mbox series

pata_parport: Fix ida_alloc return value error check

Message ID 20230204205527.16716-1-linux@zary.sk (mailing list archive)
State New, archived
Headers show
Series pata_parport: Fix ida_alloc return value error check | expand

Commit Message

Ondrej Zary Feb. 4, 2023, 8:55 p.m. UTC
pi->dev.id is unsigned so error checking of ida_alloc return value does
not work. Fix it.

Signed-off-by: Ondrej Zary <linux@zary.sk>
---
 drivers/ata/pata_parport/pata_parport.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Sergey Shtylyov Feb. 5, 2023, 7:13 p.m. UTC | #1
Hello!

On 2/4/23 11:55 PM, Ondrej Zary wrote:

> pi->dev.id is unsigned so error checking of ida_alloc return value does
> not work. Fix it.
> 
> Signed-off-by: Ondrej Zary <linux@zary.sk>

Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>

[...]

MBR, Sergey
Damien Le Moal Feb. 7, 2023, 12:02 a.m. UTC | #2
On 2/5/23 05:55, Ondrej Zary wrote:
> pi->dev.id is unsigned so error checking of ida_alloc return value does
> not work. Fix it.
> 
> Signed-off-by: Ondrej Zary <linux@zary.sk>

Applied. Thanks !
diff mbox series

Patch

diff --git a/drivers/ata/pata_parport/pata_parport.c b/drivers/ata/pata_parport/pata_parport.c
index 9e8ad93d7e59..294a266a0dda 100644
--- a/drivers/ata/pata_parport/pata_parport.c
+++ b/drivers/ata/pata_parport/pata_parport.c
@@ -424,6 +424,7 @@  static struct pi_adapter *pi_init_one(struct parport *parport,
 	struct ata_host *host;
 	struct pi_adapter *pi;
 	struct pi_device_match match = { .parport = parport, .proto = pr };
+	int id;
 
 	/*
 	 * Abort if there's a device already registered on the same parport
@@ -441,9 +442,10 @@  static struct pi_adapter *pi_init_one(struct parport *parport,
 	pi->dev.bus = &pata_parport_bus_type;
 	pi->dev.driver = &pr->driver;
 	pi->dev.release = pata_parport_dev_release;
-	pi->dev.id = ida_alloc(&pata_parport_bus_dev_ids, GFP_KERNEL);
-	if (pi->dev.id < 0)
+	id = ida_alloc(&pata_parport_bus_dev_ids, GFP_KERNEL);
+	if (id < 0)
 		return NULL; /* pata_parport_dev_release will do kfree(pi) */
+	pi->dev.id = id;
 	dev_set_name(&pi->dev, "pata_parport.%u", pi->dev.id);
 	if (device_register(&pi->dev)) {
 		put_device(&pi->dev);