Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp2927361iog; Mon, 27 Jun 2022 05:57:50 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vrAJ1vXR94kbF2m2vJcXwFvel/N7g3xIKSKkdMmiz2Vq8HpXt8CBqAwY0U6Qunp4O6Fqny X-Received: by 2002:a17:902:f78c:b0:169:b76f:2685 with SMTP id q12-20020a170902f78c00b00169b76f2685mr14388094pln.41.1656334670136; Mon, 27 Jun 2022 05:57:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656334670; cv=none; d=google.com; s=arc-20160816; b=weaWPQXATmEpgfNIIeeZFxrl0CmAzgXIRG8NrGksPHcsdwchNcn7ZwvlenHxchmL2E EEdVvvxBvFe2FCgyiOiG5fgHdPvZF1SHCOvrTaDzpEoSe/fPwSsBthEiJHGeeR68ecG+ 2b6V+zoAKEXVxYp30tgesL5p4pQIJadV3j+9VNiOz1NCBebhEah+aJFLUC0hN4HA1KBF d10WQQdUKiXJ+2j0E6sMkvsnGmmouGXqn7HjlrUXbGpp0KYycr4kbKT4GJ0LmDlxwv9B IByV017PeOLnWKoiotehWAkJf9yeMrTziIqemPAt7doxL2mJhOuY7QL+yScdkjjYkRwG 6YXA== 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=e7+7qmNgE+i+6XHtEJNivI2b+Uxq+0UVEgrhroV6NK8=; b=kxIfgrGomYFpcIY/yF3+BFRPXYmHRM1o5ykKpG44Xz7ePlUlwlFE4IUBfzYfldThTN 3fs77/wY7kZB573eG2oe8E96shRGXaDSZvN5zSpDXWMXecdhBMu4ZtftRdWzYvUzxYUL 0t3LeNNUqGJOxNTkwofd1KNI15I2gVaF3RvEvOvVy4dDZQbeLm91Tqb+gejFAd+B1hDi 3TK4ISG23lCZKD2nwOM5h3cnUyO6fV9Cy5ZE7QWjmooPbh+4eNXsxjFC0TEe2zGUDHd+ mg0SxhUUtNyGPniuIgvgF8W+Vvy/HhMaFHm1OMCAf5gGTE9EhjyJJQK/8TvZkG+qN0CK s9Cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TpzwQ2Jt; 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 d6-20020a056a0010c600b005251d1a6eeesi15109659pfu.202.2022.06.27.05.57.37; Mon, 27 Jun 2022 05:57:50 -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=TpzwQ2Jt; 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 S239493AbiF0L75 (ORCPT + 99 others); Mon, 27 Jun 2022 07:59:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238856AbiF0Lwo (ORCPT ); Mon, 27 Jun 2022 07:52:44 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A1EEDED0; Mon, 27 Jun 2022 04:46:02 -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 13E4C61187; Mon, 27 Jun 2022 11:46:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 099F7C36AEF; Mon, 27 Jun 2022 11:46:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656330361; bh=cBYTfI9m6Gk7vzGDgkegA0lWZDNMDrfWfgQxp3ZPtLM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TpzwQ2JtqPGVrLco7M7d4998eIzrTTX7JmczGxaJUlu0iyJLnnbmfetM1KbxjBm7H 6kGuXxCBAAZaTAABeP4c4B5EyNSjN7+oZa1sBKwL+qqL35o4nrCvAjFuQUJx92n8yT wbsZP/3Ca1NO+kBDn/bLtkChOSeZULI0xsoCSAzo= 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.18 135/181] iio:accel:mxc4005: rearrange iio trigger get and register Date: Mon, 27 Jun 2022 13:21:48 +0200 Message-Id: <20220627111948.603031541@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220627111944.553492442@linuxfoundation.org> References: <20220627111944.553492442@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 @@ -456,8 +456,6 @@ static int mxc4005_probe(struct i2c_clie 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) { @@ -465,6 +463,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);