From patchwork Sat Jun 18 08:59:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 70388 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp646683qgy; Sat, 18 Jun 2016 02:00:01 -0700 (PDT) X-Received: by 10.66.52.11 with SMTP id p11mr7721479pao.155.1466240401782; Sat, 18 Jun 2016 02:00:01 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id vy4si22169595pab.231.2016.06.18.02.00.01; Sat, 18 Jun 2016 02:00:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-gpio-owner@vger.kernel.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751024AbcFRJAA (ORCPT + 4 others); Sat, 18 Jun 2016 05:00:00 -0400 Received: from mail-lf0-f52.google.com ([209.85.215.52]:34157 "EHLO mail-lf0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751061AbcFRI77 (ORCPT ); Sat, 18 Jun 2016 04:59:59 -0400 Received: by mail-lf0-f52.google.com with SMTP id h129so10373932lfh.1 for ; Sat, 18 Jun 2016 01:59:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=HtHT+oBrQScnrJc5NAZUaRDs+djVotrwG1lo2ModYHs=; b=kUKfJM/nSlPZkGq/g0ThXoPMs2OxOeRRtESwJoENl9ye0qIsoY1rXANjyFJn6D82zM P1qK7d9zUMRkduJkidV8MT16CFM2G9NGNwSDbnEWYAqyDjgWwgaAXrqYUiu8oVeoCKMT DmKONCWpAVB+8AKWkmdlJgAg6h99/wfWYEtZQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=HtHT+oBrQScnrJc5NAZUaRDs+djVotrwG1lo2ModYHs=; b=Sw9CmzlQ5uufBpURH665A5uZa8OAH4HbM2dkzsU8eYFtXrV6qd5OSodDGJViT6pA/T OZhtCiSqCGvURIZvpeEJi+dMwaUsP/ImPYGQbcWvQ6Cb7qvbEiQPtFzRbONTAdzvVk1j R6+l+taT72wwdMX3HP6G7rzvP/dEfYEBqLWUKul8e2H+rlrSoCCFOindCVohXKJ7iMMO HNh0WidoiIFxEwIy9n52aZNIrer0DxVYWb1yv5j8cKvT78a2069frG8UCNB7JMOYIzpz dlSxtmHczAYvruVc2qa8N057G1+CQaXQA+Ts3qX39Zd65NXTDvJcGeDGL57fGnHsMC77 FHfw== X-Gm-Message-State: ALyK8tJuEBCY1e3dUwGC1/ySG66/FEZWb1NUS6IsxktxOAwNFXX/zVc6GneNHTPOdUszaW58 X-Received: by 10.25.27.203 with SMTP id b194mr1356984lfb.172.1466240397521; Sat, 18 Jun 2016 01:59:57 -0700 (PDT) Received: from localhost.localdomain.localdomain (c-cc7c71d5.014-348-6c756e10.cust.bredbandsbolaget.se. [213.113.124.204]) by smtp.gmail.com with ESMTPSA id f41sm5431155lji.19.2016.06.18.01.59.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Jun 2016 01:59:56 -0700 (PDT) From: Linus Walleij To: linux-gpio@vger.kernel.org, Alexandre Courbot Cc: Linus Walleij , Dan Carpenter , Walter Harms Subject: [PATCH] gpio: make the iterator point to last handle Date: Sat, 18 Jun 2016 10:59:53 +0200 Message-Id: <1466240393-28288-1-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 2.4.11 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org When initializing the GPIO handles, we use the iterator (i) to back off if something goes wrong. But since the iterator is also used after we pass the loop, we must decrement by one after exiting the loop so that we point at the last element in the array. Reported-by: Dan Carpenter Cc: Dan Carpenter Cc: Walter Harms Signed-off-by: Linus Walleij --- drivers/gpio/gpiolib.c | 2 ++ 1 file changed, 2 insertions(+) -- 2.4.11 -- To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index c826844abdeb..b504364fd644 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -474,6 +474,8 @@ static int linehandle_create(struct gpio_device *gdev, void __user *ip) dev_dbg(&gdev->dev, "registered chardev handle for line %d\n", offset); } + /* Let i point at the last handle */ + i--; lh->numdescs = handlereq.lines; fd = anon_inode_getfd("gpio-linehandle",