Skip to content

Commit 8844f0a

Browse files
Ondrej ZaryDamien Le Moal
authored andcommitted
ata: pata_parport: Fix ida_alloc return value error check
pi->dev.id is unsigned so error checking of ida_alloc return value does not work. Fix it. Signed-off-by: Ondrej Zary <[email protected]> Reviewed-by: Sergey Shtylyov <[email protected]> Signed-off-by: Damien Le Moal <[email protected]>
1 parent 72f2b0b commit 8844f0a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/ata/pata_parport/pata_parport.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,7 @@ static struct pi_adapter *pi_init_one(struct parport *parport,
424424
struct ata_host *host;
425425
struct pi_adapter *pi;
426426
struct pi_device_match match = { .parport = parport, .proto = pr };
427+
int id;
427428

428429
/*
429430
* 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,
441442
pi->dev.bus = &pata_parport_bus_type;
442443
pi->dev.driver = &pr->driver;
443444
pi->dev.release = pata_parport_dev_release;
444-
pi->dev.id = ida_alloc(&pata_parport_bus_dev_ids, GFP_KERNEL);
445-
if (pi->dev.id < 0)
445+
id = ida_alloc(&pata_parport_bus_dev_ids, GFP_KERNEL);
446+
if (id < 0)
446447
return NULL; /* pata_parport_dev_release will do kfree(pi) */
448+
pi->dev.id = id;
447449
dev_set_name(&pi->dev, "pata_parport.%u", pi->dev.id);
448450
if (device_register(&pi->dev)) {
449451
put_device(&pi->dev);

0 commit comments

Comments
 (0)