Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2833436pxv; Mon, 12 Jul 2021 03:05:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzO7MMVT9sISSErwsKpXTZvlJi/+zZGntYKMIYviuV0oAYKYSCi4+9eO06jdYaTxArsnbzd X-Received: by 2002:a92:360e:: with SMTP id d14mr36886842ila.106.1626084304858; Mon, 12 Jul 2021 03:05:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626084304; cv=none; d=google.com; s=arc-20160816; b=D4F7aEXH3HiUt7ZYqQmtU7y0g2/Mdw32u7ecoYxAuFLUlC+lheWfTgfokcVwffsIfv h5n3JA7jbzYgQ6lxkA9DAciU0k9Vn5l6FcDi638x2fvuG4m84aC/BKY6sqFtmOvkuEKG 9n7rFSsfqIexsr4XZa2LzitHEtvPkqII+fNWhWQ7FvNzqnfFhjUsp8Q5o6hvoNmI4uwm iRq1KgQ0WLjkMJa//nUeVB8YDiK56W0ZEP9NYxWzaKWdGn5vo2qm5Us1sxkfs/9Uc4Jx gXqJS3M3JlKEtMoE/t/ClcfkAgysQ3sn9OqqZC0vyJ48wBuHrJChHODamgW/VNV3vev8 +U/A== 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=TNQbFD4lCcObhs6areozqc9ezhZZipNflgpnEO72ipc=; b=KnT7jKV/3lv3qzhmCe9lbcSHRg+Tx81Vz2Gsc8QKeV/lKj4uA6aQC7ruCU+xqB3mJ2 9QTbnwmtsaJq5XgVEATqhnnoaO7PAPB26VyrN9E8HbIO3DjbuKiVmHJgQx7mLTJ2Q9rZ 19VIBZlo8dOqA4/c3dZhgIha3YWS3GfYEdJqYpjfiyr49pux2Rwbu9GJVi45Ya20KiaB ERsZlXwkOY5arRLwF0JakuefpGMAmhwBj+jeQ77R1ITEF3dvtCfVZl6D4FOurtx89hLR JBh7djpWV2mbjPqEuvVTTNQtzrcdcc1SFZgCrHLVoBW9Sgpznu3IowLmsbjESf1x4nCG G/AQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QjYrAQ84; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n5si19875867ilj.6.2021.07.12.03.04.53; Mon, 12 Jul 2021 03:05:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QjYrAQ84; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1343785AbhGLH2t (ORCPT + 99 others); Mon, 12 Jul 2021 03:28:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:34168 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241744AbhGLG7Z (ORCPT ); Mon, 12 Jul 2021 02:59:25 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8D9BD61156; Mon, 12 Jul 2021 06:56:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626072998; bh=yfM7ZqWbO13YvsM+/LpAFuOCbcq//zsYf8iFiW3mizg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QjYrAQ84zVzSbmsipFJ6sv0DnyiiiWPP4gcwyAW9/PB8Went1Fl8sQRPPwMECcll3 2HYvXZE2UcAeNhttkn78Leov1rFkFYQSNvtuj+fmz5qoOYao9/2MQsel9L5VUg64hH yVvIiQ8KJGVpEvgdiny7IgKkaW6CyNfNLI+Jn18k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jeremy Cline , Hans de Goede , Andy Shevchenko , Stable@vger.kernel.org, Jonathan Cameron Subject: [PATCH 5.12 093/700] iio: accel: bmc150: Dont make the remove function of the second accelerometer unregister itself Date: Mon, 12 Jul 2021 08:02:56 +0200 Message-Id: <20210712060937.914051025@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060924.797321836@linuxfoundation.org> References: <20210712060924.797321836@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hans de Goede commit f407e2dca0f559621114eeaf657880d83f237fbd upstream. On machines with dual accelerometers described in a single ACPI fwnode, the bmc150_accel_probe() instantiates a second i2c-client for the second accelerometer. A pointer to this manually instantiated second i2c-client is stored inside the iio_dev's private-data through bmc150_set_second_device(), so that the i2c-client can be unregistered from bmc150_accel_remove(). Before this commit bmc150_set_second_device() took only 1 argument so it would store the pointer in private-data of the iio_dev belonging to the manually instantiated i2c-client, leading to the bmc150_accel_remove() call for the second_dev trying to unregister *itself* while it was being removed, leading to a deadlock and rmmod hanging. Change bmc150_set_second_device() to take 2 arguments: 1. The i2c-client which is instantiating the second i2c-client for the 2nd accelerometer and 2. The second-device pointer itself (which also is an i2c-client). This will store the second_device pointer in the private data of the iio_dev belonging to the (ACPI instantiated) i2c-client for the first accelerometer and will make bmc150_accel_remove() unregister the second_device i2c-client when called for the first client, avoiding the deadlock. Fixes: 5bfb3a4bd8f6 ("iio: accel: bmc150: Check for a second ACPI device for BOSC0200") Cc: Jeremy Cline Signed-off-by: Hans de Goede Reviewed-by: Andy Shevchenko Cc: Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/iio/accel/bmc150-accel-core.c | 4 ++-- drivers/iio/accel/bmc150-accel-i2c.c | 2 +- drivers/iio/accel/bmc150-accel.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) --- a/drivers/iio/accel/bmc150-accel-core.c +++ b/drivers/iio/accel/bmc150-accel-core.c @@ -1811,11 +1811,11 @@ struct i2c_client *bmc150_get_second_dev } EXPORT_SYMBOL_GPL(bmc150_get_second_device); -void bmc150_set_second_device(struct i2c_client *client) +void bmc150_set_second_device(struct i2c_client *client, struct i2c_client *second_dev) { struct bmc150_accel_data *data = iio_priv(i2c_get_clientdata(client)); - data->second_device = client; + data->second_device = second_dev; } EXPORT_SYMBOL_GPL(bmc150_set_second_device); --- a/drivers/iio/accel/bmc150-accel-i2c.c +++ b/drivers/iio/accel/bmc150-accel-i2c.c @@ -70,7 +70,7 @@ static int bmc150_accel_probe(struct i2c second_dev = i2c_acpi_new_device(&client->dev, 1, &board_info); if (!IS_ERR(second_dev)) - bmc150_set_second_device(second_dev); + bmc150_set_second_device(client, second_dev); } #endif --- a/drivers/iio/accel/bmc150-accel.h +++ b/drivers/iio/accel/bmc150-accel.h @@ -18,7 +18,7 @@ int bmc150_accel_core_probe(struct devic const char *name, bool block_supported); int bmc150_accel_core_remove(struct device *dev); struct i2c_client *bmc150_get_second_device(struct i2c_client *second_device); -void bmc150_set_second_device(struct i2c_client *second_device); +void bmc150_set_second_device(struct i2c_client *client, struct i2c_client *second_dev); extern const struct dev_pm_ops bmc150_accel_pm_ops; extern const struct regmap_config bmc150_regmap_conf;