Received: by 10.223.164.202 with SMTP id h10csp129908wrb; Tue, 14 Nov 2017 12:15:45 -0800 (PST) X-Google-Smtp-Source: AGs4zMZ/d12Hb7FFf3GBaLvZNfSd13NFHiGSGGXYaQ3j6D+f8tEtABZolRC4VCcikmCuN6+B4SKB X-Received: by 10.159.218.73 with SMTP id x9mr13578529plv.259.1510690545405; Tue, 14 Nov 2017 12:15:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510690545; cv=none; d=google.com; s=arc-20160816; b=k1iCjRP8Z9SAGNOInjIv6ewlKcUPjnefsd1sccX5TLP+0VvKHlcaJWqchr14mHDtvf dZw2X0jrCwBue8ykvV/FRY/WSAEKnFB1h/UYSMDBz0b4eWgMZctXR45yWPkvTQKMV1CC +BInBAjru313oLsGMmmdsPhMGhT07jYIPvx6HtsPyqdXYrS7fgo3y8rES8NFznNx+sZU 59aOuidf+L8k95/5vke+eOmyHRLgl0gt0i2NXhYxAk8nGs5Yxw65LJWIdgf1SAABwmxo bni2TaHUa/6prFXeDdzmek2DVH7JSZKUGQC50vIc6skwlJ8faqi6wuldWtQQirSsYNj+ gOng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:date:cc:to:from:subject :message-id:arc-authentication-results; bh=V8MolnhgS2G9a4ARxSBsA1CKyIccRABe9mndl+L0h8M=; b=fcsPcrM+2lU1k/QUOz1s3URuupxOHUBBIxOegJJ+l7x+zp9XhpCCLYA1j6GkWAnsLO mS/8vfHWzbkAswXdNxNxeUfXgXCpGs5hB+VsV8MmpL1wUMPGRFwdUFr7irC/eODvAkfF EdgVa5EBNCjs7rzjUGfzyLiqKRHnPzKDDS6aNWCzeS5hGgcviUuoYKwBioe1Qcy8ln1h 9F1krR+O/KNR7r4LR5Em0cXg4btiCZAhdYtXD/tVUCPH/AXdTfe8mYXbAI3Kyx9bvs80 R6aNAhZg1e88qexuTGamXvsrS280wSjuXyKmyayE+DazmiFbBinT89x2RYuEDRs3x0fW g17Q== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=codethink.co.uk Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v5si18224004pfl.215.2017.11.14.12.15.33; Tue, 14 Nov 2017 12:15:45 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=codethink.co.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755976AbdKNUOn (ORCPT + 88 others); Tue, 14 Nov 2017 15:14:43 -0500 Received: from imap1.codethink.co.uk ([176.9.8.82]:51822 "EHLO imap1.codethink.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752151AbdKNUOj (ORCPT ); Tue, 14 Nov 2017 15:14:39 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126] helo=xylophone) by imap1.codethink.co.uk with esmtpsa (Exim 4.84_2 #1 (Debian)) id 1eEhbR-00005O-4y; Tue, 14 Nov 2017 20:14:38 +0000 Message-ID: <1510690474.18523.39.camel@codethink.co.uk> Subject: Re: [PATCH 4.4 13/56] iio: trigger: free trigger resource correctly From: Ben Hutchings To: Greg Kroah-Hartman , Alison Schofield , Jonathan Cameron Cc: stable@vger.kernel.org, Sasha Levin , LKML Date: Tue, 14 Nov 2017 20:14:34 +0000 In-Reply-To: <20171113125559.283539115@linuxfoundation.org> References: <20171113125557.613444087@linuxfoundation.org> <20171113125559.283539115@linuxfoundation.org> Organization: Codethink Ltd. Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.22.6-1+deb9u1 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2017-11-13 at 13:55 +0100, Greg Kroah-Hartman wrote: > 4.4-stable review patch.  If anyone has any objections, please let me > know. > > ------------------ > > From: Alison Schofield > > > [ Upstream commit 10e840dfb0b7fc345082dd9e5fff3c1c02e7690e ] > > These stand-alone trigger drivers were using iio_trigger_put() > where they should have been using iio_trigger_free().  The > iio_trigger_put() adds a module_put which is bad since they > never did a module_get. > > In the sysfs driver, module_get/put's are used as triggers are > added & removed. This extra module_put() occurs on an error path > in the probe routine (probably rare). > > In the bfin-timer & interrupt trigger drivers, the module resources > are not explicitly managed, so it's doing a put on something that > was never get'd.  It occurs on the probe error path and on the > remove path (not so rare). > > Tested with the sysfs trigger driver. > The bfin & interrupt drivers were build tested & inspected only. In 4.4 the iio-trig-periodic-rtc seems to have the same bug (it has been removed upstream). Would it make sense to fix it in 4.4? Ben. > Signed-off-by: Alison Schofield > Signed-off-by: Jonathan Cameron > Signed-off-by: Sasha Levin > Signed-off-by: Greg Kroah-Hartman > --- >  drivers/iio/trigger/iio-trig-interrupt.c          |    8 ++++---- >  drivers/iio/trigger/iio-trig-sysfs.c              |    2 +- >  drivers/staging/iio/trigger/iio-trig-bfin-timer.c |    4 ++-- >  3 files changed, 7 insertions(+), 7 deletions(-) > > --- a/drivers/iio/trigger/iio-trig-interrupt.c > +++ b/drivers/iio/trigger/iio-trig-interrupt.c > @@ -58,7 +58,7 @@ static int iio_interrupt_trigger_probe(s >   trig_info = kzalloc(sizeof(*trig_info), GFP_KERNEL); >   if (!trig_info) { >   ret = -ENOMEM; > - goto error_put_trigger; > + goto error_free_trigger; >   } >   iio_trigger_set_drvdata(trig, trig_info); >   trig_info->irq = irq; > @@ -83,8 +83,8 @@ error_release_irq: >   free_irq(irq, trig); >  error_free_trig_info: >   kfree(trig_info); > -error_put_trigger: > - iio_trigger_put(trig); > +error_free_trigger: > + iio_trigger_free(trig); >  error_ret: >   return ret; >  } > @@ -99,7 +99,7 @@ static int iio_interrupt_trigger_remove( >   iio_trigger_unregister(trig); >   free_irq(trig_info->irq, trig); >   kfree(trig_info); > - iio_trigger_put(trig); > + iio_trigger_free(trig); >   >   return 0; >  } > --- a/drivers/iio/trigger/iio-trig-sysfs.c > +++ b/drivers/iio/trigger/iio-trig-sysfs.c > @@ -174,7 +174,7 @@ static int iio_sysfs_trigger_probe(int i >   return 0; >   >  out2: > - iio_trigger_put(t->trig); > + iio_trigger_free(t->trig); >  free_t: >   kfree(t); >  out1: > --- a/drivers/staging/iio/trigger/iio-trig-bfin-timer.c > +++ b/drivers/staging/iio/trigger/iio-trig-bfin-timer.c > @@ -259,7 +259,7 @@ out_free_irq: >  out1: >   iio_trigger_unregister(st->trig); >  out: > - iio_trigger_put(st->trig); > + iio_trigger_free(st->trig); >   return ret; >  } >   > @@ -272,7 +272,7 @@ static int iio_bfin_tmr_trigger_remove(s >   peripheral_free(st->t->pin); >   free_irq(st->irq, st); >   iio_trigger_unregister(st->trig); > - iio_trigger_put(st->trig); > + iio_trigger_free(st->trig); >   >   return 0; >  } > > > -- Ben Hutchings Software Developer, Codethink Ltd. From 1583958365974270143@xxx Mon Nov 13 13:40:11 +0000 2017 X-GM-THRID: 1583955689243562377 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread