Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp920861imm; Thu, 13 Sep 2018 09:42:31 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZ/nVKDlPWNK5elAv9DSMCqyeC3Ca600/nY25wq3eZSyoq6fRaGQ5szor8x93m2mWaFf/+7 X-Received: by 2002:a63:a745:: with SMTP id w5-v6mr7831321pgo.374.1536856951694; Thu, 13 Sep 2018 09:42:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536856951; cv=none; d=google.com; s=arc-20160816; b=vkW3KQOjFWGI22i1VDCjCQ1T5JPr7QVD63itBr89sWcEn6uHz/L11Ex22wpo+lxvKI dHqovraJSVlpPqXl1q/FXWFCKH/8BgUV4N2RVz3LAw38/v6ca2KP5qU45SxrXcLxYWkd KmEYW1zYji9UIb9R24vysWNkvqb7cE+WIdR4cuuexUmM592IMKtjBKAdyK9r/9fp/95d lSr+1PWc2o7Vc559kAdXJosNYQtI2XejnNa0HeIYYTnhEOASUNPIW/y/X3oYuXJloFfV X5KhpNeshE2y/M9yzeHEtWrtjoBIxnjnOev/050uRT0sWTrMTiblnpcXC/8ltrUMV9Vq k3tg== 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; bh=8yEg+xxXZckld8rXqMQ+pZKdscDrNNOVARXqBm23hJs=; b=NzJqtTebt6H/ZXznGuT18u5ayMLRmOQQpw0ivyG2l6ldkzlXIPdqvIO+aCKNaoVoLp dkM3KdlmKHnp0y0U+nmRAnX2vNF0pUpRNCKGmqBUToeMSVEYnFKJbJyY3cda05YiAnug MUTxII51U/y/0h8bpfVe1/YnteEG52CNUx+WSQ/T615cCsbms60inoKLtpcqzJJMeoNv Vw3lnDcrfk6xX6lyeu5tda1+NSG7pg05SV/iREYH969Q5w/UYAeXTQdOC94Ohyib8CmL r+0TgzJp1NObxMdt4m76EGCJ2zws8bWkV0qXV4oocTZu6+L/di8mlWc7a8SFvJo1vuv5 HC9A== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k15-v6si4687590pgi.62.2018.09.13.09.42.15; Thu, 13 Sep 2018 09:42:31 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727754AbeIMVw0 (ORCPT + 99 others); Thu, 13 Sep 2018 17:52:26 -0400 Received: from jim.sh ([75.150.123.25]:56021 "EHLO psychosis.jim.sh" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726819AbeIMVw0 (ORCPT ); Thu, 13 Sep 2018 17:52:26 -0400 X-Greylist: delayed 326 seconds by postgrey-1.27 at vger.kernel.org; Thu, 13 Sep 2018 17:52:25 EDT Received: from psychosis.jim.sh (localhost [127.0.0.1]) by psychosis.jim.sh (8.14.4/8.14.4/Debian-8+deb8u2) with ESMTP id w8DGZk3X007408 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 13 Sep 2018 12:35:46 -0400 Received: (from jim@localhost) by psychosis.jim.sh (8.14.4/8.14.4/Submit) id w8DGZjv9007407; Thu, 13 Sep 2018 12:35:45 -0400 From: Jim Paris To: linux-kernel@vger.kernel.org Cc: Linus Walleij , linux-gpio@vger.kernel.org, Jim Paris , stable@vger.kernel.org Subject: [PATCH] gpiolib: fix freeing of descriptors on error Date: Thu, 13 Sep 2018 12:35:41 -0400 Message-Id: <20180913163541.7364-1-jim@jtan.com> X-Mailer: git-send-email 2.15.1 X-Virus-Scanned: clamav-milter 0.99.2 at psychosis X-Virus-Status: Clean Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When the main loop in linehandle_create() encounters an error, it fails to free one of the previously-requested GPIO descriptors. This renders the unfreed GPIO unusable until reboot, and leaves its label pointing to free'd kernel memory. Cc: stable@vger.kernel.org Fixes: ab3dbcf78f60 ("gpioib: do not free unrequested descriptors") Signed-off-by: Jim Paris --- drivers/gpio/gpiolib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index e8f8a1999393..a57300c1d649 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -571,7 +571,7 @@ static int linehandle_create(struct gpio_device *gdev, void __user *ip) if (ret) goto out_free_descs; lh->descs[i] = desc; - count = i; + count = i + 1; if (lflags & GPIOHANDLE_REQUEST_ACTIVE_LOW) set_bit(FLAG_ACTIVE_LOW, &desc->flags); -- 2.18.0