Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp6474049imb; Fri, 8 Mar 2019 20:08:42 -0800 (PST) X-Google-Smtp-Source: APXvYqxQyfKiTkisnAAODkrkI9oV6qtXWgLDPlV9IFiVsKictmGs2Em78bxvUj2E4XxJTq5rtQwv X-Received: by 2002:a63:6e8d:: with SMTP id j135mr19902236pgc.160.1552104522376; Fri, 08 Mar 2019 20:08:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1552104522; cv=none; d=google.com; s=arc-20160816; b=UiPPbJb0C1bzQ1igZzTMqfEZIGRLVsD+ViGPuxiVML0TY7hHzmril2PZxauZ1xOAnE GmXbNrJYZt6Jj8sNVzx8xNA3T7ulAawuI6E4a+Ol8UyHsxxPtzysH76EnutUGxXuSmGE ewcJv1aGUdWsyLBJWsxWnFerAfvcsiC4fgwSnZz5JdSXW25SuOidx4QShRz9YsvQWwYX ntu4hB3t2mn56InqVNmr2A1ZdqsN9RQWes/S8Lr647ulJgIMX8HzI4tzZlbIf42nQlyp VwKyUXVu4Mwvsh6U0HU2QnvacCYamS0JQfExbrnsgDaFdw3iz/z0+SojPKNGnSxcgiq2 JIlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=bgVM79Hmai3Iu8b9DNl79F0V+bI+5hG7ryZqiB3RTSo=; b=qZx3WeDei7RgFrNnZroCs4RyA78jwRYSmDI9Sb6vh6g0LLcTN7P8+ulIUmg30VeKol XST8WU0QVM7+whksEkaOtcjIw9KRxBKSvHU8oNgCmJ2ayml5SpIQnxalIxz9ltmKJBuC ZmkOq3F0IK/kAXPOHEK/Vu17UPmqxX7YJ65jARjQDzsMJxPAW2EbogkR6CthMoPnJ/D2 aZVyz5JZ6yEC9S9Mz/ou9a6xkA9wRGHZ+xIna1TcyeK8hbKEfaMJlq6yiX/mC63YByoG cJ2jXx/VVjlE2ehSlb/sZ24o53UikpMDa3JYGNX7+C0Bn14kYAt5mnUNpCOfqOQQU+hn Wf5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@umn.edu header.s=google header.b="VB3i/RKX"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=umn.edu Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a25si7883819pgm.496.2019.03.08.20.08.26; Fri, 08 Mar 2019 20:08:42 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@umn.edu header.s=google header.b="VB3i/RKX"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=umn.edu Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726544AbfCIEIH (ORCPT + 99 others); Fri, 8 Mar 2019 23:08:07 -0500 Received: from mta-p7.oit.umn.edu ([134.84.196.207]:59638 "EHLO mta-p7.oit.umn.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726432AbfCIEIG (ORCPT ); Fri, 8 Mar 2019 23:08:06 -0500 Received: from localhost (unknown [127.0.0.1]) by mta-p7.oit.umn.edu (Postfix) with ESMTP id 0E132D3E for ; Sat, 9 Mar 2019 04:08:05 +0000 (UTC) X-Virus-Scanned: amavisd-new at umn.edu Received: from mta-p7.oit.umn.edu ([127.0.0.1]) by localhost (mta-p7.oit.umn.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YHud6iJAL4mn for ; Fri, 8 Mar 2019 22:08:04 -0600 (CST) Received: from mail-it1-f200.google.com (mail-it1-f200.google.com [209.85.166.200]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mta-p7.oit.umn.edu (Postfix) with ESMTPS id D5BF5D35 for ; Fri, 8 Mar 2019 22:08:04 -0600 (CST) Received: by mail-it1-f200.google.com with SMTP id 9so13467584ita.8 for ; Fri, 08 Mar 2019 20:08:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=umn.edu; s=google; h=from:to:cc:subject:date:message-id; bh=bgVM79Hmai3Iu8b9DNl79F0V+bI+5hG7ryZqiB3RTSo=; b=VB3i/RKXuXwoQsgtHXlpxAxp8SfZUE7emiaZ35PxLqz9jvyyCkjzXMUe/pXpZjofLW HmaVMbWmJw4V7bEaSnbV3wkkLO1ie94vZO6rer3il7ClmWvoOyZUe5STvzsitl+MMz2s B4E7LzdY4zt27KCQSouf+Lt/6q152dyYsM67CQdqjJvMPQ/42of1Rr428MB05g2oXpTk BO529kQhveIyLI8inFf4K8NTD/iKlQ86kFI+4VmBkAXHRm0LJvY7e9xTGHEWe34gzVRh LMxJRc1PMjit045FRg/tPBDQ7sL8SL08yPVAABaOLgNVvFULOVlmT4bT0PTMeNEpmoM+ uJMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=bgVM79Hmai3Iu8b9DNl79F0V+bI+5hG7ryZqiB3RTSo=; b=Cc6GCTSLLDdfg038kYwAuKqPS72aExL8e5nH5Xc+ByBoCNI8lPouV3knaDuBB1ON7a zlCnUPafsBzfqpbaS2Az5q1iXukcwH5XfxRUxD3n6l67ToUdE/hzOdrI6MYTVbUEt+0j xtcWgCZCYJHqm9W+F05sxmh/eFEecTw3n2EfVcH0XTzAzp2vfR7Av/CiJ7z4o+MH39O+ DmgQQAKwWZvrIoQ1jGq3CISuMerZUHyi7t6nWDIv+M1ePY3gbamsASGq62VTnksmCO5f 9wxdO2Fvkj7gaaY2wYecbmzQFjghRDXVsvO4M7/1R1rrlZWp6LfZ9WE00p6B6nB7dSJk FGYA== X-Gm-Message-State: APjAAAXim81HvXy0cqr/Jnr7Z6ICfZJPwjwh6aj/xzyBzD0CNXu5DhVP DiElpZbpHIvNEf96OTbnUpom+/D/Gz56imvBuah9AI8pRyLbBRzfAFqbee1+LmGiNOqdl/ohDGt XUdp9p2gs9J9rkV9IOl9XvXfvXYav X-Received: by 2002:a6b:6007:: with SMTP id r7mr11287614iog.124.1552104484437; Fri, 08 Mar 2019 20:08:04 -0800 (PST) X-Received: by 2002:a6b:6007:: with SMTP id r7mr11287610iog.124.1552104484203; Fri, 08 Mar 2019 20:08:04 -0800 (PST) Received: from bee.dtc.umn.edu (cs-bee-u.cs.umn.edu. [128.101.106.63]) by smtp.gmail.com with ESMTPSA id r70sm4985570ita.42.2019.03.08.20.08.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Mar 2019 20:08:03 -0800 (PST) From: Kangjie Lu To: kjlu@umn.edu Cc: pakki001@umn.edu, Linus Walleij , Bartosz Golaszewski , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] gpio: add a check for the return value of ida_simple_get fails Date: Fri, 8 Mar 2019 22:07:57 -0600 Message-Id: <20190309040757.924-1-kjlu@umn.edu> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ida_simple_get may fail and return a negative error number. The fix checks its return value; if it fails, go to err_destroy. Signed-off-by: Kangjie Lu --- drivers/gpio/gpio-exar.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpio/gpio-exar.c b/drivers/gpio/gpio-exar.c index 0ecd2369c2ca..a09d2f9ebacc 100644 --- a/drivers/gpio/gpio-exar.c +++ b/drivers/gpio/gpio-exar.c @@ -148,6 +148,8 @@ static int gpio_exar_probe(struct platform_device *pdev) mutex_init(&exar_gpio->lock); index = ida_simple_get(&ida_index, 0, 0, GFP_KERNEL); + if (index < 0) + goto err_destroy; sprintf(exar_gpio->name, "exar_gpio%d", index); exar_gpio->gpio_chip.label = exar_gpio->name; -- 2.17.1