From patchwork Thu Mar 23 10:40:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 9640809 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A7A74602CA for ; Thu, 23 Mar 2017 10:41:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A97AA27C14 for ; Thu, 23 Mar 2017 10:41:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9BDB428438; Thu, 23 Mar 2017 10:41:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BA4DF27C14 for ; Thu, 23 Mar 2017 10:41:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Subject:To:From :Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=ASqmwtryDmpVPF9/J4ZG0n0nhfZF+ChueYpvDROPUqQ=; b=hrfWZjbRwrnIqb 0k2gbNTx40XfJPQSjWBVOC4aFRwPwJLaBCohdK5ebn/JxVuP0zo59SoX/CIzbeKlDdyp+JERxm5PL Hi0T1hWhPfXowvc+kRmyMQBwlqJbY7xESxmu9X/vZa4FK96BgWs0/yBx4C4NHgp+wWMFrzqiK/6u+ QOjUF+Dezv3i4P/3mhlrHVXQQiH91WEW4gYZ1RcYyvW+MrA2A5IRaguMd+zFiLFcnsannMqqbn3VX xvfj55YaoBUEdJ4c0gx/NpvZMC4U8tH8UihC9mFyNZ9ndgKinloQpUbp3ZT713rUwf8+0j9WP2CrX smpAeDCm71WssoQxgMCA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cr0BL-0005ye-37; Thu, 23 Mar 2017 10:41:27 +0000 Received: from aserp1040.oracle.com ([141.146.126.69]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cr0BI-0005TF-2m for linux-mediatek@lists.infradead.org; Thu, 23 Mar 2017 10:41:26 +0000 Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v2NAex9D020151 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 23 Mar 2017 10:40:59 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id v2NAexST016036 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 23 Mar 2017 10:40:59 GMT Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id v2NAeuhB012736; Thu, 23 Mar 2017 10:40:57 GMT Received: from mwanda (/154.0.138.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 23 Mar 2017 03:40:56 -0700 Date: Thu, 23 Mar 2017 13:40:49 +0300 From: Dan Carpenter To: Richard Purdie , Sean Wang Subject: [PATCH] leds: mt6323: Fix an off by one bug in probe Message-ID: <20170323104049.GC20154@mwanda> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.6.0 (2016-04-01) X-Source-IP: aserv0022.oracle.com [141.146.126.234] X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170323_034124_234267_9A57A899 X-CRM114-Status: UNSURE ( 6.41 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kernel-janitors@vger.kernel.org, linux-mediatek@lists.infradead.org, Jacek Anaszewski , Pavel Machek , Matthias Brugger , linux-leds@vger.kernel.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP It should be ">= MT6323_MAX_LEDS" instead of ">". Also "reg" is a u32 so it can't be negative and we can remove the test for negative values. Fixes: 216ec6cc4c19 ("leds: Add LED support for MT6323 PMIC") Signed-off-by: Dan Carpenter Acked-by: Pavel Machek diff --git a/drivers/leds/leds-mt6323.c b/drivers/leds/leds-mt6323.c index 48081bccbea5..8893c74e9a1f 100644 --- a/drivers/leds/leds-mt6323.c +++ b/drivers/leds/leds-mt6323.c @@ -417,7 +417,7 @@ static int mt6323_led_probe(struct platform_device *pdev) goto put_child_node; } - if (reg < 0 || reg > MT6323_MAX_LEDS || leds->led[reg]) { + if (reg >= MT6323_MAX_LEDS || leds->led[reg]) { dev_err(dev, "Invalid led reg %u\n", reg); ret = -EINVAL; goto put_child_node;