From: Denis CIOCCA <denis.ciocca@st.com>
To: linux-iio@vger.kernel.org
Cc: Denis Ciocca <denis.ciocca@st.com>
Subject: [PATCH 3/4] iio:magnetometer: call devm_iio_device_free function if common_proble fails
Date: Fri, 14 Feb 2014 16:16:42 +0100 [thread overview]
Message-ID: <1392391005-2719-4-git-send-email-denis.ciocca@st.com> (raw)
In-Reply-To: <1392391005-2719-1-git-send-email-denis.ciocca@st.com>
If st_magn_common_probe function fails, the device must be freed.
Added devm_iio_device_free also on common_remove function.
Signed-off-by: Denis Ciocca <denis.ciocca@st.com>
---
drivers/iio/magnetometer/st_magn_core.c | 1 +
drivers/iio/magnetometer/st_magn_i2c.c | 6 +++++-
drivers/iio/magnetometer/st_magn_spi.c | 6 +++++-
3 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/magnetometer/st_magn_core.c b/drivers/iio/magnetometer/st_magn_core.c
index 52bbcfa..018f01c 100644
--- a/drivers/iio/magnetometer/st_magn_core.c
+++ b/drivers/iio/magnetometer/st_magn_core.c
@@ -408,6 +408,7 @@ void st_magn_common_remove(struct iio_dev *indio_dev)
st_sensors_deallocate_trigger(indio_dev);
st_magn_deallocate_ring(indio_dev);
+ devm_iio_device_free(mdata->dev, indio_dev);
}
EXPORT_SYMBOL(st_magn_common_remove);
diff --git a/drivers/iio/magnetometer/st_magn_i2c.c b/drivers/iio/magnetometer/st_magn_i2c.c
index 892e0fe..5e33e2d 100644
--- a/drivers/iio/magnetometer/st_magn_i2c.c
+++ b/drivers/iio/magnetometer/st_magn_i2c.c
@@ -36,9 +36,13 @@ static int st_magn_i2c_probe(struct i2c_client *client,
err = st_magn_common_probe(indio_dev, NULL);
if (err < 0)
- return err;
+ goto device_unregister;
return 0;
+
+device_unregister:
+ devm_iio_device_free(&client->dev, indio_dev);
+ return err;
}
static int st_magn_i2c_remove(struct i2c_client *client)
diff --git a/drivers/iio/magnetometer/st_magn_spi.c b/drivers/iio/magnetometer/st_magn_spi.c
index a6143ea..09c5845 100644
--- a/drivers/iio/magnetometer/st_magn_spi.c
+++ b/drivers/iio/magnetometer/st_magn_spi.c
@@ -35,9 +35,13 @@ static int st_magn_spi_probe(struct spi_device *spi)
err = st_magn_common_probe(indio_dev, NULL);
if (err < 0)
- return err;
+ goto device_unregister;
return 0;
+
+device_unregister:
+ devm_iio_device_free(&spi->dev, indio_dev);
+ return err;
}
static int st_magn_spi_remove(struct spi_device *spi)
--
1.8.5.4
next prev parent reply other threads:[~2014-02-14 15:16 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-14 15:16 use devm_iio_device_free on common probe failed and remove Denis CIOCCA
2014-02-14 15:16 ` [PATCH 1/4] iio:accel: call devm_iio_device_free function if common_proble fails Denis CIOCCA
2014-02-14 16:11 ` Lars-Peter Clausen
2014-02-15 9:47 ` Jonathan Cameron
2014-02-14 15:16 ` [PATCH 2/4] iio:gyro: " Denis CIOCCA
2014-02-14 15:16 ` Denis CIOCCA [this message]
2014-02-14 15:16 ` [PATCH 4/4] iio:pressure: " Denis CIOCCA
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1392391005-2719-4-git-send-email-denis.ciocca@st.com \
--to=denis.ciocca@st.com \
--cc=linux-iio@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).