Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1142305imm; Thu, 13 Sep 2018 13:25:41 -0700 (PDT) X-Google-Smtp-Source: ANB0Vda0tN3HyI5UItQhUZEmjFeLj0eBQYRlSbawDNTT11Ki/DXacXI+dGY8qNldH+y0io3HsYxw X-Received: by 2002:a17:902:6b89:: with SMTP id p9-v6mr8726743plk.272.1536870341334; Thu, 13 Sep 2018 13:25:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536870341; cv=none; d=google.com; s=arc-20160816; b=d4oybsVFCALfkty8S/s0ZMQq7Qm9SuOOf3V11l3HzKp034htvxr5LPvgNfIzwTdH6b QTW5GaDtq4EFEPHfXSpfvR0feal4QA5haPdKHkut0AABrqn7fOBH7oExheszWSd9XaCl DyhA6p/TIYtBHFLqGLw6iyDEQu1PIYMOFAQYLksLGDv1trfsp/ZJk4/pG8yBxVLa4BzQ bvZYcV+6n2a8uZ/mQmhbWrRjNChIpDnuu2GpOHq3c2wHg1UHBJSDezZ7j3pwjXMGNzp5 6QwPBo5Vu5TAathBVHZPY/zxKup6i/GkBbCaxkJf1DCFs2bfCq+YewsgWOj5U4y/3uNG G49g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=23cXMf47zlG+EXF0BN9s0/N/8EQyzAWSeFPZ7wusQ0M=; b=XFiYM+ICWjKcIyWm16+gGBPNghniM1UUVoL3QAfgAplQIQdKs3LruZpTN7NvfVaN25 JPaAy5hvOrHC9V++kGcuDSLIUitQagIHAcl/41Dx6xsIao7qCC/NB0HZVHLAO9MeGbBc FswY2BE2eltoUJb/wh4lGoXEyaH6Oc51qTllCHBs1hCMKOGeR2XTzWhNZgQu/C4Rj3UB MMiNqoRDlMHnpfsLfJn8UxPE8DBpT9RoPVzUBPj+Gz0BD5CV3jmDg+tgZyTk4SxrhLwI P+P34YlYDh76XQm9TTcBkZllmofGapXZZS9zpFoQ4+RFZghKn613LPp5aCH2r/p8gPXI QNXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=sQdjBkur; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u11-v6si5083872pgg.683.2018.09.13.13.24.57; Thu, 13 Sep 2018 13:25:41 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=sQdjBkur; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727818AbeINBHZ (ORCPT + 99 others); Thu, 13 Sep 2018 21:07:25 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:45104 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726824AbeINBHZ (ORCPT ); Thu, 13 Sep 2018 21:07:25 -0400 Received: by mail-lf1-f65.google.com with SMTP id r4-v6so5862658lff.12; Thu, 13 Sep 2018 12:56:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=23cXMf47zlG+EXF0BN9s0/N/8EQyzAWSeFPZ7wusQ0M=; b=sQdjBkurYhDtyIpVEU5d1yW1iamI4km64Sxb+pQNBQJj5ssnxId7QM0NxrU3U2P9Ez Txh98jT1VJo9/owj2Pl8uTX1OMJkb970op9CbVWpl3/ijndjPfwtLv4BPNPcxsLC8mM4 H0/+MjB/0FGrDC3yMU/Rx2Ns16AzbHDUHOf3ufy6rJaXZ9YLaNEtjCfxdAwNOkO0fnTa XrYft/satqpr5qEpgoLZLqU+GxzoTaDmesvADADDRfSBpUtaMEqUOwFoAqnVwskG35Lg meuhKmHrocl8jRjwgz6090jGzGQjUEZBYW9+8OMDmBDlcC2u+rXMT929xmFalF71GLsQ DS0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=23cXMf47zlG+EXF0BN9s0/N/8EQyzAWSeFPZ7wusQ0M=; b=A683z67/nLEBov22djSIg1Z3rtW8hmEFQCcHAwzoBXFZPxJkOf4OWs3LtWcxNdXqbN /Q43r9e4XSuDoVdq4Tn5iVAnNLII3DmMAIE9V6KyEcU1zzV6Kp344MD6MUnSHeTssyRv ABdutoU2vfQ8n1nOOvz+F2b61z+UrAZLHdp59ngp6TlM2wH1/bHyYwfFTpFT61yGtbPW Miu3b9T3WKbPrlojpFZbXeCWIxtuKW+TLFub0lTNjTc8FJsfvlOKhLZBs8EYnBExoCSj 6X8zEmaTVvCjAptzT2/IujpcJhh/R6fFXM23mP8o2duQIUtiQLrHTD/dxN80xHgEA9+c ztiA== X-Gm-Message-State: APzg51A/j9rIQy0rmhN7qvx8an35leW23oaGCPoGDbPKNVYwooWA1R2G cq2/LNYTwTWG8oHhvoRVQqolQ0kfgPOms1UPQk0= X-Received: by 2002:a19:4a09:: with SMTP id x9-v6mr6171212lfa.80.1536868584754; Thu, 13 Sep 2018 12:56:24 -0700 (PDT) MIME-Version: 1.0 References: <20180913163541.7364-1-jim@jtan.com> In-Reply-To: <20180913163541.7364-1-jim@jtan.com> From: Ricardo Ribalda Delgado Date: Thu, 13 Sep 2018 21:56:08 +0200 Message-ID: Subject: Re: [PATCH] gpiolib: fix freeing of descriptors on error To: Jim Paris Cc: LKML , Linus Walleij , linux-gpio@vger.kernel.org, stable@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jim I have sent an identical patch 3 hours before you [1] ;) Seems that we are working on the same stuff. Cheers [1] https://www.spinics.net/lists/linux-gpio/msg32541.html On Thu, Sep 13, 2018 at 6:42 PM Jim Paris wrote: > > 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 > -- Ricardo Ribalda