Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp2910460iog; Mon, 27 Jun 2022 05:35:14 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tiPJZgTWRDoQKzqFZjGK2vFGFyV7zJMJC5dVSosTbKkGQJKP5ZmOwuUyiEwJc7bkJd/cA+ X-Received: by 2002:a17:907:7f1d:b0:71d:ea75:e533 with SMTP id qf29-20020a1709077f1d00b0071dea75e533mr12908064ejc.78.1656333314156; Mon, 27 Jun 2022 05:35:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656333314; cv=none; d=google.com; s=arc-20160816; b=fhL2c3KiEyNVa8j5L5jWl1t8ew4w/s2A71Vs8ZOjjUpnkQMWSknC7LDrZ7y0T6JDb1 KIcgPQCebso6uXk9tH/Oa/Fkq2qD94tSKm+k992nl/GI+IiiRZwd4vD7v8Kz2hIYDJ3r xfUCG/rhMdaT1/ogXNVd5ZYOIeBcsI1wIFDcztIf0ITXTOEUI94LNZWvubJrK6qSCIG5 yuBf5CHwqLBHiqHOh2Vy3NUX1kVzQXWq2k0Ghk6DevimUeRw9sLUDJgppq17h4+8AJt8 1hVNxBfYfnnuWKb8nibYDoq/UBdXFNRufjh+IS/43KDsIQTwYVzAhXdUhcEuu3ThSz51 Qpmg== 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=5Cbu3ZWX2e96O1GAC5k9YXd1otXtV2S/wFVKAOUeHi0=; b=HOGAAH9mKKtxmL3C1aBRSSipvuuiGX2tjmTg4FPhHDzIbOijLtTbX7Jifq1p8xUqI6 85bQk4EiMOnN64hSV+dNkyv88655t1JOGeEkM3WDeaIeUoXJKnfpx6C1HSJnX+wIc+uy 3tM5QQVbKPD9+bAfA6GLkGbIOXwpBxZBazIJTdZYNN2BUiqEt+eSgNxxPz5Jjha+OW5f dH8i73i9eU0EH+LSJZUKo5R2nBz8iuzOZmfcUwRhmAg0lEkOEoBKV7rAlZ/5VSc1Yc+P ZK4K/nUYxI2HISqkLg1Gj55kksA3/3wCFvyBWrJvtn05z534YTvMOSiOYFxT0CFn28rI YjLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=x69AsPKM; 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 x16-20020a05640226d000b004355a7e1499si14933936edd.367.2022.06.27.05.34.47; Mon, 27 Jun 2022 05:35:14 -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=x69AsPKM; 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 S235759AbiF0LeN (ORCPT + 99 others); Mon, 27 Jun 2022 07:34:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235891AbiF0Lcx (ORCPT ); Mon, 27 Jun 2022 07:32:53 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32A9CAD; Mon, 27 Jun 2022 04:29:48 -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 03EC1B8111A; Mon, 27 Jun 2022 11:29:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 591CFC3411D; Mon, 27 Jun 2022 11:29:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656329385; bh=e6qYBuNvaK9vJWUNHSGQdFOs57yjXaAesaxvVanYtg0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=x69AsPKMugb/Xdy9r9rXb7VCx3MwuaQfOg8DESYbP1D3XPdWjnbLlFNS1dwDVurJ4 K4Q5pQT5Z2LmDQjU5mYp8r6K6HLBGzBVFlRd1AtIC1PL0OhiaHyeCi98tA3bX/5Yvd oLAnHv+MoXkPU/BCHfwN9fHPFkEMBt58FpS8Zghs= 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 40/60] iio:accel:mxc4005: rearrange iio trigger get and register Date: Mon, 27 Jun 2022 13:21:51 +0200 Message-Id: <20220627111928.869433949@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 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 @@ -462,8 +462,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) { @@ -471,6 +469,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);