Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2717913pxv; Sun, 11 Jul 2021 23:41:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx8yo3yB/ewQNDQGcchYw8ObpVnC3feoqq8aPSZeKJrHqqRcwEiA7sErE8PZlDdXhGWJdwr X-Received: by 2002:a17:907:96a4:: with SMTP id hd36mr37466895ejc.251.1626072098902; Sun, 11 Jul 2021 23:41:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626072098; cv=none; d=google.com; s=arc-20160816; b=lgKQIZREPgZMUxvTu4+W7VzMjMnjX8y2v8QG49OPdOkAN95Nl+atTObLilqr8WpUQP 8cZnR39/n25kGwMG/PXkAFVSZhrHJxWCGPNe+EwZ05pxMPBvkV4uUgW1y1Z8B3CAEVGy OBg0wv01tcADbDcuX4/B6ZReBIfffjEbqz2vRlMfkxbK6eSkLQAzK3LtcRr8PhSs1rIJ bfl9BxC0OJLH1y/ZFyAmxRFb9zM/frU9GHq6bVAp5pMXocMSFFyPhvf2dkx8dNkQIAwV NVQR59PrIxMprPeM9RSoeCuVmatnnZqxzOLYe+Xhke72hQIqjFwl/xfcZbrihh9zsfkk +jvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=YOL+DlNVB6Sv93eKa6Rc+ATqw96iK3oKbAJ6BIaBWeU=; b=sHqapoqn3A1FoIVEatG+oEr0qZ6h81+7IIkhJSXjQJ9cLAElZD7JBbNKFOI5XXDpA7 DzaAHyFxbq7EpB9CTClzhTflG1MEiBKsgBiMAlrU3OPfVzq66ksUDmPBJon+p61N/Uj8 ykrcCN9VHxbVdr6z2MLtfVi4VlMciwX2eGOJ+9pWMiG8YU94/8cujXPb1miHS0sOzw9q wVBWurgYvL146H46snzyK1e3HdlqX76aR0zlu5OtgaKc5aQyV2cCwpmH7h/wl0HCoB46 Bv86n2maQtvo/W14pa0KEAxflQdBbdnIPHkOz/H1wPk9tcWyiwPWN84aXyEzDQrH4K++ LzIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OAdUoluh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ba10si16451598edb.363.2021.07.11.23.41.16; Sun, 11 Jul 2021 23:41:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OAdUoluh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236898AbhGLGmt (ORCPT + 99 others); Mon, 12 Jul 2021 02:42:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:54238 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237497AbhGLGec (ORCPT ); Mon, 12 Jul 2021 02:34:32 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id DF0D9610CA; Mon, 12 Jul 2021 06:30:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626071443; bh=0G7WDUneSnvB3wdCJmnVPCLfW7xqQoNe83QOSnntyTs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OAdUoluhBtltGfpUXCCbmolgsYv1CB8gAvsQUpJVb74IENIbt1g/tQv1iA/Mc6tEm iS0N+vCyDr/1WPZbSnznqEzjPB5SOSElKNIOxNnejZIU61lCOuk0sT0EY6wIE0ZPJm JiKpJEPj9Yhv1YyUs453fFp/Pb2mEN20rm5QFe2E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, frank zago , Stable@vger.kernel.org, Jonathan Cameron Subject: [PATCH 5.10 073/593] iio: light: tcs3472: do not free unallocated IRQ Date: Mon, 12 Jul 2021 08:03:53 +0200 Message-Id: <20210712060851.173417192@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060843.180606720@linuxfoundation.org> References: <20210712060843.180606720@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: frank zago commit 7cd04c863f9e1655d607705455e7714f24451984 upstream. Allocating an IRQ is conditional to the IRQ existence, but freeing it was not. If no IRQ was allocate, the driver would still try to free IRQ 0. Add the missing checks. This fixes the following trace when the driver is removed: [ 100.667788] Trying to free already-free IRQ 0 [ 100.667793] WARNING: CPU: 0 PID: 2315 at kernel/irq/manage.c:1826 free_irq+0x1fd/0x370 ... [ 100.667914] Call Trace: [ 100.667920] tcs3472_remove+0x3a/0x90 [tcs3472] [ 100.667927] i2c_device_remove+0x2b/0xa0 Signed-off-by: frank zago Link: https://lore.kernel.org/r/20210427022017.19314-2-frank@zago.net Fixes: 9d2f715d592e ("iio: light: tcs3472: support out-of-threshold events") Cc: Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/iio/light/tcs3472.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/drivers/iio/light/tcs3472.c +++ b/drivers/iio/light/tcs3472.c @@ -531,7 +531,8 @@ static int tcs3472_probe(struct i2c_clie return 0; free_irq: - free_irq(client->irq, indio_dev); + if (client->irq) + free_irq(client->irq, indio_dev); buffer_cleanup: iio_triggered_buffer_cleanup(indio_dev); return ret; @@ -559,7 +560,8 @@ static int tcs3472_remove(struct i2c_cli struct iio_dev *indio_dev = i2c_get_clientdata(client); iio_device_unregister(indio_dev); - free_irq(client->irq, indio_dev); + if (client->irq) + free_irq(client->irq, indio_dev); iio_triggered_buffer_cleanup(indio_dev); tcs3472_powerdown(iio_priv(indio_dev));