Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp652686iog; Thu, 30 Jun 2022 07:43:58 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tSh1qqVZcC2qW4e3tcXFIa8SR549MeOKt4bGQpWwjHzlIM7UHiYx1rNlJubErG0HOR/9Gd X-Received: by 2002:a17:906:9f0c:b0:712:1b55:37e1 with SMTP id fy12-20020a1709069f0c00b007121b5537e1mr9258469ejc.69.1656600238131; Thu, 30 Jun 2022 07:43:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656600238; cv=none; d=google.com; s=arc-20160816; b=YqP0mTwSkJ0aQx1FbdSOH+KrT0m2ekEHqFd9FOk4lmUpJEQ5pDvtgC4D60LV/zI3Hm 3omOKT7nz1c5K7sDnYbVOtdh8cJf61HVEvlAD7RB3ExlwjDriB0l5pSStwlbS4xD/S6F i/FSTPXe02WDTyHxkszrBVf0usrneSG43as9MJ5I6iyHiiZO4fTzW4pOndsgXzhq9cOJ rPo+baV0/wIPcnMrJvtEtzP88WNGKieEuhX13mLTm5CQ05B6KbW7vFH3ls2zmlz9V+mf 3VB2amnjyE04pLHBRCplAeDyYBcsO08/ENaH4UfWvXZg5u8L24a4KDAgmeReviBMrRW5 rEdg== 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=Lwtm/iWgOJyLU/weFVnPGQ5nYkVzohVjhu155bfKXBE=; b=BHLewE2oQxA8rNSMPDd74tLgndi8kG95i5/Ku6xzaRaM3Qa/kc8AluYhVMNmslQnqQ a0Sx9H+dh+MMNOojck624nlTC+v1gXjPsv1I2hx+FW1zpfC+WpKFQpJeu8ZT5uAbikUu WJnbV4FGvvUaajS9PsincCeD0sY3R2k2El3nn0elsLfiD6LMsMPTjvLpzxS9gf0ugdYD s9p8lm/qd//XGWCK8+CrWtyJ1ZTJGh+WsPgptE+isCqmnXSWcVkRfbLnf4vdWbjKWbwo L5YkehSDFchzcdRSiLeoITpSeNNPDD3tIvKYP91B/5lLEUnJIR6oo0tmbwcCO8ZaHReK 9Jug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="ZoerRl/u"; 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 cr13-20020a170906d54d00b0072642116126si21026009ejc.888.2022.06.30.07.43.31; Thu, 30 Jun 2022 07:43:58 -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="ZoerRl/u"; 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 S236188AbiF3OA0 (ORCPT + 99 others); Thu, 30 Jun 2022 10:00:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236525AbiF3N7D (ORCPT ); Thu, 30 Jun 2022 09:59:03 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC414427C4; Thu, 30 Jun 2022 06:51:53 -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 ams.source.kernel.org (Postfix) with ESMTPS id 437B8B82AED; Thu, 30 Jun 2022 13:51:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 974BBC34115; Thu, 30 Jun 2022 13:51:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656597089; bh=X8JUC66ow/6HI6++cQqPQ7voqNEha44XQ01WnUiymBM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZoerRl/u/dB2Fuc2/TZswtUAKofknkcLikvW1mDUn2UyYpSEe/iSmQiQeIUpRrvHA jTbGiz4t8O3EGCwd9SLitAe9uvMuYOwanRHMaR5ZqUR2XYYzs8lSg3CAzAt9wORArA Suaauo0XADRALiHZwmYlMboHxf6lMDhp3SH7SGhw= 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 4.19 24/49] iio:chemical:ccs811: rearrange iio trigger get and register Date: Thu, 30 Jun 2022 15:46:37 +0200 Message-Id: <20220630133234.612211320@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220630133233.910803744@linuxfoundation.org> References: <20220630133233.910803744@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 @@ -421,11 +421,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,