Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp2928069iog; Mon, 27 Jun 2022 05:58:52 -0700 (PDT) X-Google-Smtp-Source: AGRyM1swvx48/laMjOfUTHLM4+4pKn15kkMI5eSfkCzUoDOcGwkJmi5C/XMIJAEjSUxx+KVdUzlo X-Received: by 2002:a05:6a00:885:b0:510:950f:f787 with SMTP id q5-20020a056a00088500b00510950ff787mr14341275pfj.83.1656334731778; Mon, 27 Jun 2022 05:58:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656334731; cv=none; d=google.com; s=arc-20160816; b=G+DVwvuFVfrN7hyblJCVXpdbXkHJq+t9fLTVyMm2/abbIaX6T9YwcfOted0G1vrBHD 4EhQSOgYYA/3ONSHpQ7/0VWotLLeUm/AyDg8RQVAzyNLGj0Rfue05IWF426XllCOOlyc j9bYuMLsnQsDe8ik3qUBYZeBSDQlGP1Qx2w4MIsZ/cFtFZYp+2m1Zzrd0vg72lUV30Ck /EsQ9t7NIatZlRYh5IZgEkyDT7qA/zItN+yvbPR09MyDeeCwzbcybvURiT8xGvi8gci6 xGu8P3bmnCNGRKBGfdzYtwpET7Gt4SpFP8jN9A06IQCBlhWiTQawMve6qKK/ouQik7Bk /TDQ== 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=tW6cDKuHIRdP2UcbLSiYzyDN0fc1HXDg5Hm92aPyd5o=; b=CAM4TSj5l46TDntfI3DQ+km2cSn/CAhxEE4E/6ILrC82nQVQkjobuwFt80ZAmtxH57 v0qKcZPjTyQ5UMk2KIQ9aA2IUoGFRJaLlVuu2ZG+RIZvuiVSP/G6KArdfWXq/Ge2TMmA BpULhaAh7950dlCxgLnX3PdMi5s6W95TrHLozASeOJZi/yeTa0jJymMji22zs9g53dBD x+0GiWrSuc3sSl80t10alF8vYdEEeeVVeOYJWQdZMDBjk5g7iaW4r4Or7xSMM1F5PWJh ZowV1/8UHd2S3yX73kcpIyslnJZ0zspYd+c3/KH+h9Ru2iyOeTh3luAa+9FSsfnvXM68 0ZcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dysWHhTY; 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 qe11-20020a17090b4f8b00b001df8f8d3daasi11036557pjb.162.2022.06.27.05.58.40; Mon, 27 Jun 2022 05:58:51 -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=dysWHhTY; 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 S235107AbiF0L10 (ORCPT + 99 others); Mon, 27 Jun 2022 07:27:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235088AbiF0L0g (ORCPT ); Mon, 27 Jun 2022 07:26:36 -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 1186B657B; Mon, 27 Jun 2022 04:26:19 -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 A697F614A4; Mon, 27 Jun 2022 11:26:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B79D0C3411D; Mon, 27 Jun 2022 11:26:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656329178; bh=+3NWgB8HIlGFeNlKiovmSOs5fC1vXOQkzR7b4yd8WeM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dysWHhTYM/HvRaKGGs6oIxJC0U90eKSv2ARBOQLMLLF9jGVBUXKnJdPhL+08uqvog /WPk94KllM+R+sH9lx7s7nNvaaflJbkX54N7e8rqkZm8boUjV2GwgzRDgvdBkCA3yL Fx6l2GjV+rt9c1EMfpA/wuTgbqR+w3xwYZFbaujk= 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 075/102] iio:accel:mxc4005: rearrange iio trigger get and register Date: Mon, 27 Jun 2022 13:21:26 +0200 Message-Id: <20220627111935.694114966@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 9354c224c9b4f55847a0de3e968cba2ebf15af3b 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: 47196620c82f ("iio: mxc4005: add data ready trigger for mxc4005") Signed-off-by: Dmitry Rokosov Reviewed-by: Andy Shevchenko Link: https://lore.kernel.org/r/20220524181150.9240-4-ddrokosov@sberdevices.ru Cc: Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/iio/accel/mxc4005.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/iio/accel/mxc4005.c +++ b/drivers/iio/accel/mxc4005.c @@ -461,8 +461,6 @@ static int mxc4005_probe(struct i2c_clie data->dready_trig->dev.parent = &client->dev; data->dready_trig->ops = &mxc4005_trigger_ops; iio_trigger_set_drvdata(data->dready_trig, indio_dev); - indio_dev->trig = data->dready_trig; - iio_trigger_get(indio_dev->trig); ret = devm_iio_trigger_register(&client->dev, data->dready_trig); if (ret) { @@ -470,6 +468,8 @@ static int mxc4005_probe(struct i2c_clie "failed to register trigger\n"); return ret; } + + indio_dev->trig = iio_trigger_get(data->dready_trig); } return devm_iio_device_register(&client->dev, indio_dev);