Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp2908466iog; Mon, 27 Jun 2022 05:33:17 -0700 (PDT) X-Google-Smtp-Source: AGRyM1s32bBUKihxUh6HEAuREBAvWVjkM0hVYhM+0giKmZx7KjgL3jn7F/Z01LwnLK5Mnpg5ToBV X-Received: by 2002:a17:907:7ea2:b0:726:c0e5:e997 with SMTP id qb34-20020a1709077ea200b00726c0e5e997mr837574ejc.35.1656333197384; Mon, 27 Jun 2022 05:33:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656333197; cv=none; d=google.com; s=arc-20160816; b=niZTQeOLkfx1cQPtsoM+MHsOi2ipueD1iVMORXxoX3q4kuXuqjFLpmy28s8Nk0bA6g LiBolSWtsbZfyKelaCL862kGXqop8kbDr0yxUn6scFRhtdDJ007nRNfMASsKMZjVf4dO zAKn03TmVn7mncaPFaYuTG68C2aX47LMJJ0k3N00pw7AwMjeoEZwBNlR9jnKfVXvmJ8C HFQiG4FkE7FwpRpsqQCE+WOfEO88P+M5e+CgOCFHkiUpwStBvf/DB9LeCr627Uluxv5y ognJrZOk+l9oXStD1LVn7iBaxRQLAUN9/SQCky5YnTQnOzsZ7mcozdtUtVWbMtHveuS3 lOIg== 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=4VqPHsRvCs3Q8+o0zUaJs2HSFbHitRwIWZOzQkSr7o4=; b=dgP2RFUFdOWsakwfltsTGEfwq5ar1BAJYuLD2EoN7lq2XueMrPiLeTWwGz/PUatYTC VfNS6IRNdhuSOZ81WaEZ1C5tLWsqaegTl8ZbMfn/mwHKP77OcBiom1cB9GMFzRAbKgAN 7NLRJPdDvtkXfWT6c4hmKCti9wMEW7L5LygjZaWGiZjmw77ire9oC2wvIy5HInpQaDm+ dML8YnIvqCmIgOz6z1A+cwHZe9BgrKaISU7zo+aRXuY8NBXwXphvAe+FP/1uzcBpUrlK mHxlNlZxWD3t1mXZLi/9cx9NIdC6T2tL/aLlncUKwvBOqIzQzyzfszF526e2BlxuBKQy xO4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="AWeWtBW/"; 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 gn9-20020a1709070d0900b007235473b2fbsi14929047ejc.680.2022.06.27.05.32.52; Mon, 27 Jun 2022 05:33:17 -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="AWeWtBW/"; 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 S236104AbiF0Lfb (ORCPT + 99 others); Mon, 27 Jun 2022 07:35:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235801AbiF0Lcp (ORCPT ); Mon, 27 Jun 2022 07:32:45 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 001CAB84E; Mon, 27 Jun 2022 04:29:41 -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 3F0BD614E6; Mon, 27 Jun 2022 11:29:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 365D9C3411D; Mon, 27 Jun 2022 11:29:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656329379; bh=e5SxuUVBR5YTS1lsaIKWd96E4rewCB1yPA1mZtrYxBA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AWeWtBW/08IOOfIxeflalEhRf/nzHpGpOST7JUDQ5Kis2RlfjkakB9dVcRUjjSNBA kRMwH7hWMv/X03j28m8WknHP/fBenkuCOTOBjbmZK736LbkLeBk81x3DVTnscDhhdX AU52eAk2oKNNci/TFVI11LvyF3t0Bvn0ACJpL5U0= 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.4 38/60] iio:chemical:ccs811: rearrange iio trigger get and register Date: Mon, 27 Jun 2022 13:21:49 +0200 Message-Id: <20220627111928.811227872@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220627111927.641837068@linuxfoundation.org> References: <20220627111927.641837068@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 @@ -418,11 +418,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,