From patchwork Sat Feb 4 20:55:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ondrej Zary X-Patchwork-Id: 52821 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1505981wrn; Sat, 4 Feb 2023 13:03:25 -0800 (PST) X-Google-Smtp-Source: AK7set8HgbPO0YRaFd3baC5jy4d6g3/lHEdpFqm7+R9S6DcCHunmGJH+fhg3qeYVal8fbVLri9sF X-Received: by 2002:a17:906:6d42:b0:88c:3a48:715b with SMTP id a2-20020a1709066d4200b0088c3a48715bmr15094733ejt.30.1675544605012; Sat, 04 Feb 2023 13:03:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675544604; cv=none; d=google.com; s=arc-20160816; b=NrGYw68YdR166FCDIbYNgW+oo/EZlRzp91A3A2OcBDeQyN+NyN2FubxlzBWN7IPQBe hbTQ9HQ3ufJqZgeNDGjOVKszmbl2BVZ+XaU4rF7ZnRcy19ezadyHXs6M/ItwRBbhzmQe z6TmB5FUyiFFgUuL+yiMEYowMmAvnfoReoGkqnNV/iA9VdFRRHxTRYc0SFyGq8Aq1tv8 PBRxk0Pn0Aw8BjLUS9ggbXxCnYx3MWSRnES1MrBSme5au+wTtMwNF6uR1w067sKpCdLQ JMF+ofK/8lbL5s8rxiU+QA+mMn7aXpR+JMkhvyKa1dInwKzb44A804pk1condTPLYVfO kNpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Y1YfwPXgICyWSRJYpbNbj9u8fYWOW+pKNYJ07XMxOog=; b=gVabeXaKh3lgdGcTuEfK0imxn4wcw3vvFHUakYkWN5WWXnoAk/BJKEm/aUr01Cjxof VTrgHuQc5xKmAxAi2qYj0lyJ6PyrmQZMwdsMzwSufyi8zo7aeMW3GwcTxlUNNZHsoqLY Eg/zCmupVsltyO4r3zc0X0Fos+ABoA7gvCbovaa3EQZgFTSE7RmE/obZ0Ex/cMaG3tXh KaJRk+mo2h5Z+fKPGx6CS1uBYurDfEtvcdCbvvRNht73WEkmTjUDne4DQNlSwXwFQU6F VkncjrRKMRKLEws1hSYxRnW2DP6zYBdGFZLiKFSoq6Kzbl0IJTy6rYAc+H2/vr4hiw5c DWjg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mv11-20020a170907838b00b00878272927e3si5997955ejc.285.2023.02.04.13.02.58; Sat, 04 Feb 2023 13:03:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232640AbjBDUzj (ORCPT + 99 others); Sat, 4 Feb 2023 15:55:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229448AbjBDUzh (ORCPT ); Sat, 4 Feb 2023 15:55:37 -0500 Received: from hosting.gsystem.sk (hosting.gsystem.sk [212.5.213.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5C4671C337; Sat, 4 Feb 2023 12:55:36 -0800 (PST) Received: from gsql.ggedos.sk (off-20.infotel.telecom.sk [212.5.213.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by hosting.gsystem.sk (Postfix) with ESMTPSA id 90B747A028D; Sat, 4 Feb 2023 21:55:33 +0100 (CET) From: Ondrej Zary To: Damien Le Moal Cc: Dan Carpenter , Christoph Hellwig , Sergey Shtylyov , Jens Axboe , Tim Waugh , 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 Message-Id: <20230204205527.16716-1-linux@zary.sk> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756935859562367279?= X-GMAIL-MSGID: =?utf-8?q?1756935859562367279?= pi->dev.id is unsigned so error checking of ida_alloc return value does not work. Fix it. Signed-off-by: Ondrej Zary Reviewed-by: Sergey Shtylyov --- 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);