Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp2889210iog; Mon, 27 Jun 2022 05:09:13 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uyH4nx8h0JKRlAa198Bf/IE/EGmtVn1jiCJFCjS7mxeYclEjvccJveqYB+H0XZof5E9uZk X-Received: by 2002:a05:6402:2c4:b0:435:8ce0:aef8 with SMTP id b4-20020a05640202c400b004358ce0aef8mr15833964edx.140.1656331753286; Mon, 27 Jun 2022 05:09:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656331753; cv=none; d=google.com; s=arc-20160816; b=QdY51hwr/uwlubM31urrekTCfJMrtgR7bvnN5UOjUxrieKuZacoa2c971NekIrSkRH jgPOjxmdtHx8/XNxzIR/ajcJIHCeDidV5nAy03yPNl66tmafVWjGLJTxgkm3P1UhJ4Is F3K6jcrpxnQpyZVyxYRN2mywGQH5utsvN/GeEb7VrHSU/hWyQOS9NDyVQ44b4ucFBofL BP7tWwGnoLZRnx1wpDNiykfnup+wHczjYta3sHkB3v+VsJRbV1ohVJTBfRDgv8y6CjqG qC5jJAZsXf10EbtmaIkCm6A0iHj0HBQcbx0lPSo3oqMUparimg1/a91iMe0nC6Ly/ZGD xh/g== 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=6OxRX94ow+5HyiIbI++s0jYx0dJWfal4QcYZfcIQ384=; b=C+dsFA0ZxxEamcE90F8n5rHmL3oH0ErOt1YahZov/8oFmBTRsKz7BjLMUIi706+KXm LoZjlZ2LXIm6XBxeqLpXdHmopwCMV+/vdACWQtKAwqWZXBnpp5FGmvhbhHDzIzSNgdPi FC8ecnc3YdPxz7bFbkVgqPcuxA46uPAZoOs3A+OqMwSPs3/U/1DdYf0s6auPnaZJSf7a uR6DwpHG6XC6tRwHqqwsQKziD9WLdrYcrRhGm3Oe9IZvmolEOSogAzewWkLTSvbKsH4p Ich1VNdOhsllNixijEUjdW5Dtm9u6vOPOlgjuL7RLeopmfPj1RSo3lYgGce37u0h3arb 6TnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tEn9wJBw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i19-20020a1709064fd300b00711f164117csi12955612ejw.883.2022.06.27.05.08.48; Mon, 27 Jun 2022 05:09:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tEn9wJBw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S235216AbiF0L1W (ORCPT + 99 others); Mon, 27 Jun 2022 07:27:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233236AbiF0L0f (ORCPT ); Mon, 27 Jun 2022 07:26:35 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4AE0795B3; Mon, 27 Jun 2022 04:26:13 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id DB962614A2; Mon, 27 Jun 2022 11:26:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E56E0C3411D; Mon, 27 Jun 2022 11:26:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656329172; bh=YEWPxdckj3HbKhMDZMzBuatDvbXySe6JrnuwUn0KqiM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tEn9wJBweli80b5adlDn4iAsnPP5Cx3fR6/qpQtPFlniKkTs9qyF6iwS4r9PfFIlL FxLF3w0SrGhpXMZn1aTiVUiOoMjx50es/GzR3y4B95AE9Hg61NTj79PHU3aAp1MzuB GrHmwVe1EAzqWsuMIuFNwGdF0J2gDiFX0zMbM+Qw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dmitry Rokosov , Andy Shevchenko , Stable@vger.kernel.org, Jonathan Cameron Subject: [PATCH 5.10 073/102] iio:chemical:ccs811: rearrange iio trigger get and register Date: Mon, 27 Jun 2022 13:21:24 +0200 Message-Id: <20220627111935.635574402@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220627111933.455024953@linuxfoundation.org> References: <20220627111933.455024953@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dmitry Rokosov commit d710359c0b445e8c03e24f19ae2fb79ce7282260 upstream. IIO trigger interface function iio_trigger_get() should be called after iio_trigger_register() (or its devm analogue) strictly, because of iio_trigger_get() acquires module refcnt based on the trigger->owner pointer, which is initialized inside iio_trigger_register() to THIS_MODULE. If this call order is wrong, the next iio_trigger_put() (from sysfs callback or "delete module" path) will dereference "default" module refcnt, which is incorrect behaviour. Fixes: f1f065d7ac30 ("iio: chemical: ccs811: Add support for data ready trigger") Signed-off-by: Dmitry Rokosov Reviewed-by: Andy Shevchenko Link: https://lore.kernel.org/r/20220524181150.9240-5-ddrokosov@sberdevices.ru Cc: Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/iio/chemical/ccs811.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/iio/chemical/ccs811.c +++ b/drivers/iio/chemical/ccs811.c @@ -500,11 +500,11 @@ static int ccs811_probe(struct i2c_clien data->drdy_trig->dev.parent = &client->dev; data->drdy_trig->ops = &ccs811_trigger_ops; iio_trigger_set_drvdata(data->drdy_trig, indio_dev); - indio_dev->trig = data->drdy_trig; - iio_trigger_get(indio_dev->trig); ret = iio_trigger_register(data->drdy_trig); if (ret) goto err_poweroff; + + indio_dev->trig = iio_trigger_get(data->drdy_trig); } ret = iio_triggered_buffer_setup(indio_dev, NULL,