mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ondrej Zary <linux@zary.sk>
To: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Cc: Dan Carpenter <error27@gmail.com>, Christoph Hellwig <hch@lst.de>,
	Sergey Shtylyov <s.shtylyov@omp.ru>, Jens Axboe <axboe@kernel.dk>,
	Tim Waugh <tim@cyberelk.net>,
	linux-block@vger.kernel.org, linux-parport@lists.infradead.org,
	linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] pata_parport: Fix ida_alloc return value error check
Date: Sat,  4 Feb 2023 21:55:27 +0100	[thread overview]
Message-ID: <20230204205527.16716-1-linux@zary.sk> (raw)
In-Reply-To: <Y9uwqRothHhaOeDO@kili>

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(-)

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);
-- 
Ondrej Zary


       reply	other threads:[~2023-02-04 20:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <Y9uwqRothHhaOeDO@kili>
2023-02-04 20:55 ` Ondrej Zary [this message]
2023-02-05 19:13   ` Sergey Shtylyov
2023-02-07  0:02   ` Damien Le Moal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230204205527.16716-1-linux@zary.sk \
    --to=linux@zary.sk \
    --cc=axboe@kernel.dk \
    --cc=damien.lemoal@opensource.wdc.com \
    --cc=error27@gmail.com \
    --cc=hch@lst.de \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-parport@lists.infradead.org \
    --cc=s.shtylyov@omp.ru \
    --cc=tim@cyberelk.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®