* [PATCH v3 1/6] iio: accel: hid-sensor-accel-3d: Fix memory leak in probe()
@ 2015-05-13 18:06 Fabio Estevam
2015-05-13 18:06 ` [PATCH v3 2/6] iio: gyro: hid-sensor-gyro-3d: " Fabio Estevam
` (5 more replies)
0 siblings, 6 replies; 18+ messages in thread
From: Fabio Estevam @ 2015-05-13 18:06 UTC (permalink / raw)
To: jic23; +Cc: srinivas.pandruvada, linux-iio, Fabio Estevam
From: Fabio Estevam <fabio.estevam@freescale.com>
'channels' is allocated via kmemdup and it is never freed in the
subsequent error paths.
Use 'indio_dev->channels' directly instead, so that we avoid such
memory leak problem.
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
Build-tested only.
Changes since v2:
- Properly align "accel_3d_parse_report(" in multiple lines
Changes since v1:
- Make clear in the commit log that the proble only occurs in the error
paths
drivers/iio/accel/hid-sensor-accel-3d.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/drivers/iio/accel/hid-sensor-accel-3d.c b/drivers/iio/accel/hid-sensor-accel-3d.c
index 2b4fad6..b933957 100644
--- a/drivers/iio/accel/hid-sensor-accel-3d.c
+++ b/drivers/iio/accel/hid-sensor-accel-3d.c
@@ -299,7 +299,6 @@ static int hid_accel_3d_probe(struct platform_device *pdev)
struct iio_dev *indio_dev;
struct accel_3d_state *accel_state;
struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data;
- struct iio_chan_spec *channels;
indio_dev = devm_iio_device_alloc(&pdev->dev,
sizeof(struct accel_3d_state));
@@ -320,21 +319,21 @@ static int hid_accel_3d_probe(struct platform_device *pdev)
return ret;
}
- channels = kmemdup(accel_3d_channels, sizeof(accel_3d_channels),
- GFP_KERNEL);
- if (!channels) {
+ indio_dev->channels = kmemdup(accel_3d_channels,
+ sizeof(accel_3d_channels), GFP_KERNEL);
+ if (!indio_dev->channels) {
dev_err(&pdev->dev, "failed to duplicate channels\n");
return -ENOMEM;
}
- ret = accel_3d_parse_report(pdev, hsdev, channels,
- HID_USAGE_SENSOR_ACCEL_3D, accel_state);
+ ret = accel_3d_parse_report(pdev, hsdev,
+ (struct iio_chan_spec *)indio_dev->channels,
+ HID_USAGE_SENSOR_ACCEL_3D, accel_state);
if (ret) {
dev_err(&pdev->dev, "failed to setup attributes\n");
goto error_free_dev_mem;
}
- indio_dev->channels = channels;
indio_dev->num_channels = ARRAY_SIZE(accel_3d_channels);
indio_dev->dev.parent = &pdev->dev;
indio_dev->info = &accel_3d_info;
--
1.9.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v3 2/6] iio: gyro: hid-sensor-gyro-3d: Fix memory leak in probe()
2015-05-13 18:06 [PATCH v3 1/6] iio: accel: hid-sensor-accel-3d: Fix memory leak in probe() Fabio Estevam
@ 2015-05-13 18:06 ` Fabio Estevam
2015-05-13 18:52 ` Srinivas Pandruvada
2015-05-13 18:06 ` [PATCH v3 3/6] iio: light: hid-sensor-als.c: " Fabio Estevam
` (4 subsequent siblings)
5 siblings, 1 reply; 18+ messages in thread
From: Fabio Estevam @ 2015-05-13 18:06 UTC (permalink / raw)
To: jic23; +Cc: srinivas.pandruvada, linux-iio, Fabio Estevam
From: Fabio Estevam <fabio.estevam@freescale.com>
'channels' is allocated via kmemdup and it is never freed in the
subsequent error paths.
Use 'indio_dev->channels' directly instead, so that we avoid such
memory leak problem.
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
Build-tested only.
Changes since v2:
- None
Changes since v1:
- Make clear in the commit log that the proble only occurs in the error
paths
drivers/iio/gyro/hid-sensor-gyro-3d.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/drivers/iio/gyro/hid-sensor-gyro-3d.c b/drivers/iio/gyro/hid-sensor-gyro-3d.c
index b5883b6..7b60b58 100644
--- a/drivers/iio/gyro/hid-sensor-gyro-3d.c
+++ b/drivers/iio/gyro/hid-sensor-gyro-3d.c
@@ -298,7 +298,6 @@ static int hid_gyro_3d_probe(struct platform_device *pdev)
struct iio_dev *indio_dev;
struct gyro_3d_state *gyro_state;
struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data;
- struct iio_chan_spec *channels;
indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*gyro_state));
if (!indio_dev)
@@ -317,21 +316,21 @@ static int hid_gyro_3d_probe(struct platform_device *pdev)
return ret;
}
- channels = kmemdup(gyro_3d_channels, sizeof(gyro_3d_channels),
- GFP_KERNEL);
- if (!channels) {
+ indio_dev->channels = kmemdup(gyro_3d_channels,
+ sizeof(gyro_3d_channels), GFP_KERNEL);
+ if (!indio_dev->channels) {
dev_err(&pdev->dev, "failed to duplicate channels\n");
return -ENOMEM;
}
- ret = gyro_3d_parse_report(pdev, hsdev, channels,
- HID_USAGE_SENSOR_GYRO_3D, gyro_state);
+ ret = gyro_3d_parse_report(pdev, hsdev,
+ (struct iio_chan_spec *)indio_dev->channels,
+ HID_USAGE_SENSOR_GYRO_3D, gyro_state);
if (ret) {
dev_err(&pdev->dev, "failed to setup attributes\n");
goto error_free_dev_mem;
}
- indio_dev->channels = channels;
indio_dev->num_channels = ARRAY_SIZE(gyro_3d_channels);
indio_dev->dev.parent = &pdev->dev;
indio_dev->info = &gyro_3d_info;
--
1.9.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v3 3/6] iio: light: hid-sensor-als.c: Fix memory leak in probe()
2015-05-13 18:06 [PATCH v3 1/6] iio: accel: hid-sensor-accel-3d: Fix memory leak in probe() Fabio Estevam
2015-05-13 18:06 ` [PATCH v3 2/6] iio: gyro: hid-sensor-gyro-3d: " Fabio Estevam
@ 2015-05-13 18:06 ` Fabio Estevam
2015-05-13 18:52 ` Srinivas Pandruvada
2015-05-13 18:06 ` [PATCH v3 4/6] iio: orientation: hid-sensor-incl-3d: " Fabio Estevam
` (3 subsequent siblings)
5 siblings, 1 reply; 18+ messages in thread
From: Fabio Estevam @ 2015-05-13 18:06 UTC (permalink / raw)
To: jic23; +Cc: srinivas.pandruvada, linux-iio, Fabio Estevam
From: Fabio Estevam <fabio.estevam@freescale.com>
'channels' is allocated via kmemdup and it is never freed in the
subsequent error paths.
Use 'indio_dev->channels' directly instead, so that we avoid such
memory leak problem.
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
Build-tested only.
Changes since v2:
- None
Changes since v1:
- Make clear in the commit log that the proble only occurs in the error
paths
drivers/iio/light/hid-sensor-als.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/iio/light/hid-sensor-als.c b/drivers/iio/light/hid-sensor-als.c
index 1609ecd..9d74364 100644
--- a/drivers/iio/light/hid-sensor-als.c
+++ b/drivers/iio/light/hid-sensor-als.c
@@ -263,7 +263,6 @@ static int hid_als_probe(struct platform_device *pdev)
struct iio_dev *indio_dev;
struct als_state *als_state;
struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data;
- struct iio_chan_spec *channels;
indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(struct als_state));
if (!indio_dev)
@@ -281,20 +280,21 @@ static int hid_als_probe(struct platform_device *pdev)
return ret;
}
- channels = kmemdup(als_channels, sizeof(als_channels), GFP_KERNEL);
- if (!channels) {
+ indio_dev->channels = kmemdup(als_channels,
+ sizeof(als_channels), GFP_KERNEL);
+ if (!indio_dev->channels) {
dev_err(&pdev->dev, "failed to duplicate channels\n");
return -ENOMEM;
}
- ret = als_parse_report(pdev, hsdev, channels,
- HID_USAGE_SENSOR_ALS, als_state);
+ ret = als_parse_report(pdev, hsdev,
+ (struct iio_chan_spec *)indio_dev->channels,
+ HID_USAGE_SENSOR_ALS, als_state);
if (ret) {
dev_err(&pdev->dev, "failed to setup attributes\n");
goto error_free_dev_mem;
}
- indio_dev->channels = channels;
indio_dev->num_channels =
ARRAY_SIZE(als_channels);
indio_dev->dev.parent = &pdev->dev;
--
1.9.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v3 4/6] iio: orientation: hid-sensor-incl-3d: Fix memory leak in probe()
2015-05-13 18:06 [PATCH v3 1/6] iio: accel: hid-sensor-accel-3d: Fix memory leak in probe() Fabio Estevam
2015-05-13 18:06 ` [PATCH v3 2/6] iio: gyro: hid-sensor-gyro-3d: " Fabio Estevam
2015-05-13 18:06 ` [PATCH v3 3/6] iio: light: hid-sensor-als.c: " Fabio Estevam
@ 2015-05-13 18:06 ` Fabio Estevam
2015-05-13 18:54 ` Srinivas Pandruvada
2015-05-13 18:06 ` [PATCH v3 5/6] iio: orientation: hid-sensor-rotation: " Fabio Estevam
` (2 subsequent siblings)
5 siblings, 1 reply; 18+ messages in thread
From: Fabio Estevam @ 2015-05-13 18:06 UTC (permalink / raw)
To: jic23; +Cc: srinivas.pandruvada, linux-iio, Fabio Estevam
From: Fabio Estevam <fabio.estevam@freescale.com>
'channels' is allocated via kmemdup and it is never freed in the
subsequent error paths.
Use 'indio_dev->channels' directly instead, so that we avoid such
memory leak problem.
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
Build-tested only.
Changes since v2:
- None
Changes since v1:
- Make clear in the commit log that the proble only occurs in the error
paths
drivers/iio/orientation/hid-sensor-incl-3d.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/iio/orientation/hid-sensor-incl-3d.c b/drivers/iio/orientation/hid-sensor-incl-3d.c
index 5930fa3..2eb49a8 100644
--- a/drivers/iio/orientation/hid-sensor-incl-3d.c
+++ b/drivers/iio/orientation/hid-sensor-incl-3d.c
@@ -315,7 +315,6 @@ static int hid_incl_3d_probe(struct platform_device *pdev)
struct iio_dev *indio_dev;
struct incl_3d_state *incl_state;
struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data;
- struct iio_chan_spec *channels;
indio_dev = devm_iio_device_alloc(&pdev->dev,
sizeof(struct incl_3d_state));
@@ -336,21 +335,22 @@ static int hid_incl_3d_probe(struct platform_device *pdev)
return ret;
}
- channels = kmemdup(incl_3d_channels, sizeof(incl_3d_channels),
- GFP_KERNEL);
- if (!channels) {
+ indio_dev->channels = kmemdup(incl_3d_channels,
+ sizeof(incl_3d_channels), GFP_KERNEL);
+ if (!indio_dev->channels) {
dev_err(&pdev->dev, "failed to duplicate channels\n");
return -ENOMEM;
}
- ret = incl_3d_parse_report(pdev, hsdev, channels,
- HID_USAGE_SENSOR_INCLINOMETER_3D, incl_state);
+ ret = incl_3d_parse_report(pdev, hsdev,
+ (struct iio_chan_spec *)indio_dev->channels,
+ HID_USAGE_SENSOR_INCLINOMETER_3D,
+ incl_state);
if (ret) {
dev_err(&pdev->dev, "failed to setup attributes\n");
goto error_free_dev_mem;
}
- indio_dev->channels = channels;
indio_dev->num_channels = ARRAY_SIZE(incl_3d_channels);
indio_dev->dev.parent = &pdev->dev;
indio_dev->info = &incl_3d_info;
--
1.9.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v3 5/6] iio: orientation: hid-sensor-rotation: Fix memory leak in probe()
2015-05-13 18:06 [PATCH v3 1/6] iio: accel: hid-sensor-accel-3d: Fix memory leak in probe() Fabio Estevam
` (2 preceding siblings ...)
2015-05-13 18:06 ` [PATCH v3 4/6] iio: orientation: hid-sensor-incl-3d: " Fabio Estevam
@ 2015-05-13 18:06 ` Fabio Estevam
2015-05-13 19:03 ` Srinivas Pandruvada
2015-05-13 18:06 ` [PATCH v3 6/6] iio: pressure: hid-sensor-press: " Fabio Estevam
2015-05-13 18:51 ` [PATCH v3 1/6] iio: accel: hid-sensor-accel-3d: " Srinivas Pandruvada
5 siblings, 1 reply; 18+ messages in thread
From: Fabio Estevam @ 2015-05-13 18:06 UTC (permalink / raw)
To: jic23; +Cc: srinivas.pandruvada, linux-iio, Fabio Estevam
From: Fabio Estevam <fabio.estevam@freescale.com>
'channels' is allocated via kmemdup and it is never freed in the
subsequent error paths.
Use 'indio_dev->channels' directly instead, so that we avoid such
memory leak problem.
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
Build-tested only.
Changes since v2:
- None
Changes since v1:
- Make clear in the commit log that the proble only occurs in the error
paths
drivers/iio/orientation/hid-sensor-rotation.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/drivers/iio/orientation/hid-sensor-rotation.c b/drivers/iio/orientation/hid-sensor-rotation.c
index 4afb6c7..b6ee50f 100644
--- a/drivers/iio/orientation/hid-sensor-rotation.c
+++ b/drivers/iio/orientation/hid-sensor-rotation.c
@@ -222,7 +222,6 @@ static int hid_dev_rot_probe(struct platform_device *pdev)
struct iio_dev *indio_dev;
struct dev_rot_state *rot_state;
struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data;
- struct iio_chan_spec *channels;
indio_dev = devm_iio_device_alloc(&pdev->dev,
sizeof(struct dev_rot_state));
@@ -243,21 +242,23 @@ static int hid_dev_rot_probe(struct platform_device *pdev)
return ret;
}
- channels = devm_kmemdup(&pdev->dev, dev_rot_channels,
- sizeof(dev_rot_channels), GFP_KERNEL);
- if (!channels) {
+ indio_dev->channels = devm_kmemdup(&pdev->dev, dev_rot_channels,
+ sizeof(dev_rot_channels),
+ GFP_KERNEL);
+ if (!indio_dev->channels) {
dev_err(&pdev->dev, "failed to duplicate channels\n");
return -ENOMEM;
}
- ret = dev_rot_parse_report(pdev, hsdev, channels,
- HID_USAGE_SENSOR_DEVICE_ORIENTATION, rot_state);
+ ret = dev_rot_parse_report(pdev, hsdev,
+ (struct iio_chan_spec *)indio_dev->channels,
+ HID_USAGE_SENSOR_DEVICE_ORIENTATION,
+ rot_state);
if (ret) {
dev_err(&pdev->dev, "failed to setup attributes\n");
return ret;
}
- indio_dev->channels = channels;
indio_dev->num_channels = ARRAY_SIZE(dev_rot_channels);
indio_dev->dev.parent = &pdev->dev;
indio_dev->info = &dev_rot_info;
--
1.9.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v3 6/6] iio: pressure: hid-sensor-press: Fix memory leak in probe()
2015-05-13 18:06 [PATCH v3 1/6] iio: accel: hid-sensor-accel-3d: Fix memory leak in probe() Fabio Estevam
` (3 preceding siblings ...)
2015-05-13 18:06 ` [PATCH v3 5/6] iio: orientation: hid-sensor-rotation: " Fabio Estevam
@ 2015-05-13 18:06 ` Fabio Estevam
2015-05-13 19:03 ` Srinivas Pandruvada
2015-05-13 18:51 ` [PATCH v3 1/6] iio: accel: hid-sensor-accel-3d: " Srinivas Pandruvada
5 siblings, 1 reply; 18+ messages in thread
From: Fabio Estevam @ 2015-05-13 18:06 UTC (permalink / raw)
To: jic23; +Cc: srinivas.pandruvada, linux-iio, Fabio Estevam
From: Fabio Estevam <fabio.estevam@freescale.com>
'channels' is allocated via kmemdup and it is never freed in the
subsequent error paths.
Use 'indio_dev->channels' directly instead, so that we avoid such
memory leak problem.
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
Build-tested only.
Changes since v2:
- Properly align "press_parse_report(" in multiple lines
Changes since v1:
- Make clear in the commit log that the proble only occurs in the error
paths
drivers/iio/pressure/hid-sensor-press.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/iio/pressure/hid-sensor-press.c b/drivers/iio/pressure/hid-sensor-press.c
index 7bb8d4c..5a10dbc 100644
--- a/drivers/iio/pressure/hid-sensor-press.c
+++ b/drivers/iio/pressure/hid-sensor-press.c
@@ -262,7 +262,6 @@ static int hid_press_probe(struct platform_device *pdev)
struct iio_dev *indio_dev;
struct press_state *press_state;
struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data;
- struct iio_chan_spec *channels;
indio_dev = devm_iio_device_alloc(&pdev->dev,
sizeof(struct press_state));
@@ -282,20 +281,21 @@ static int hid_press_probe(struct platform_device *pdev)
return ret;
}
- channels = kmemdup(press_channels, sizeof(press_channels), GFP_KERNEL);
- if (!channels) {
+ indio_dev->channels = kmemdup(press_channels, sizeof(press_channels),
+ GFP_KERNEL);
+ if (!indio_dev->channels) {
dev_err(&pdev->dev, "failed to duplicate channels\n");
return -ENOMEM;
}
- ret = press_parse_report(pdev, hsdev, channels,
- HID_USAGE_SENSOR_PRESSURE, press_state);
+ ret = press_parse_report(pdev, hsdev,
+ (struct iio_chan_spec *)indio_dev->channels,
+ HID_USAGE_SENSOR_PRESSURE, press_state);
if (ret) {
dev_err(&pdev->dev, "failed to setup attributes\n");
goto error_free_dev_mem;
}
- indio_dev->channels = channels;
indio_dev->num_channels =
ARRAY_SIZE(press_channels);
indio_dev->dev.parent = &pdev->dev;
--
1.9.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH v3 1/6] iio: accel: hid-sensor-accel-3d: Fix memory leak in probe()
2015-05-13 18:06 [PATCH v3 1/6] iio: accel: hid-sensor-accel-3d: Fix memory leak in probe() Fabio Estevam
` (4 preceding siblings ...)
2015-05-13 18:06 ` [PATCH v3 6/6] iio: pressure: hid-sensor-press: " Fabio Estevam
@ 2015-05-13 18:51 ` Srinivas Pandruvada
2015-05-17 8:09 ` Jonathan Cameron
5 siblings, 1 reply; 18+ messages in thread
From: Srinivas Pandruvada @ 2015-05-13 18:51 UTC (permalink / raw)
To: Fabio Estevam; +Cc: jic23, linux-iio, Fabio Estevam
On Wed, 2015-05-13 at 15:06 -0300, Fabio Estevam wrote:
> From: Fabio Estevam <fabio.estevam@freescale.com>
>
> 'channels' is allocated via kmemdup and it is never freed in the
> subsequent error paths.
>
> Use 'indio_dev->channels' directly instead, so that we avoid such
> memory leak problem.
>
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
Reviewed-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
> ---
> Build-tested only.
>
> Changes since v2:
> - Properly align "accel_3d_parse_report(" in multiple lines
> Changes since v1:
> - Make clear in the commit log that the proble only occurs in the error
> paths
>
> drivers/iio/accel/hid-sensor-accel-3d.c | 13 ++++++-------
> 1 file changed, 6 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/iio/accel/hid-sensor-accel-3d.c b/drivers/iio/accel/hid-sensor-accel-3d.c
> index 2b4fad6..b933957 100644
> --- a/drivers/iio/accel/hid-sensor-accel-3d.c
> +++ b/drivers/iio/accel/hid-sensor-accel-3d.c
> @@ -299,7 +299,6 @@ static int hid_accel_3d_probe(struct platform_device *pdev)
> struct iio_dev *indio_dev;
> struct accel_3d_state *accel_state;
> struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data;
> - struct iio_chan_spec *channels;
>
> indio_dev = devm_iio_device_alloc(&pdev->dev,
> sizeof(struct accel_3d_state));
> @@ -320,21 +319,21 @@ static int hid_accel_3d_probe(struct platform_device *pdev)
> return ret;
> }
>
> - channels = kmemdup(accel_3d_channels, sizeof(accel_3d_channels),
> - GFP_KERNEL);
> - if (!channels) {
> + indio_dev->channels = kmemdup(accel_3d_channels,
> + sizeof(accel_3d_channels), GFP_KERNEL);
> + if (!indio_dev->channels) {
> dev_err(&pdev->dev, "failed to duplicate channels\n");
> return -ENOMEM;
> }
>
> - ret = accel_3d_parse_report(pdev, hsdev, channels,
> - HID_USAGE_SENSOR_ACCEL_3D, accel_state);
> + ret = accel_3d_parse_report(pdev, hsdev,
> + (struct iio_chan_spec *)indio_dev->channels,
> + HID_USAGE_SENSOR_ACCEL_3D, accel_state);
> if (ret) {
> dev_err(&pdev->dev, "failed to setup attributes\n");
> goto error_free_dev_mem;
> }
>
> - indio_dev->channels = channels;
> indio_dev->num_channels = ARRAY_SIZE(accel_3d_channels);
> indio_dev->dev.parent = &pdev->dev;
> indio_dev->info = &accel_3d_info;
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v3 2/6] iio: gyro: hid-sensor-gyro-3d: Fix memory leak in probe()
2015-05-13 18:06 ` [PATCH v3 2/6] iio: gyro: hid-sensor-gyro-3d: " Fabio Estevam
@ 2015-05-13 18:52 ` Srinivas Pandruvada
2015-05-17 8:10 ` Jonathan Cameron
0 siblings, 1 reply; 18+ messages in thread
From: Srinivas Pandruvada @ 2015-05-13 18:52 UTC (permalink / raw)
To: Fabio Estevam; +Cc: jic23, linux-iio, Fabio Estevam
On Wed, 2015-05-13 at 15:06 -0300, Fabio Estevam wrote:
> From: Fabio Estevam <fabio.estevam@freescale.com>
>
> 'channels' is allocated via kmemdup and it is never freed in the
> subsequent error paths.
>
> Use 'indio_dev->channels' directly instead, so that we avoid such
> memory leak problem.
>
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
Reviewed-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
> ---
> Build-tested only.
>
> Changes since v2:
> - None
> Changes since v1:
> - Make clear in the commit log that the proble only occurs in the error
> paths
>
> drivers/iio/gyro/hid-sensor-gyro-3d.c | 13 ++++++-------
> 1 file changed, 6 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/iio/gyro/hid-sensor-gyro-3d.c b/drivers/iio/gyro/hid-sensor-gyro-3d.c
> index b5883b6..7b60b58 100644
> --- a/drivers/iio/gyro/hid-sensor-gyro-3d.c
> +++ b/drivers/iio/gyro/hid-sensor-gyro-3d.c
> @@ -298,7 +298,6 @@ static int hid_gyro_3d_probe(struct platform_device *pdev)
> struct iio_dev *indio_dev;
> struct gyro_3d_state *gyro_state;
> struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data;
> - struct iio_chan_spec *channels;
>
> indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*gyro_state));
> if (!indio_dev)
> @@ -317,21 +316,21 @@ static int hid_gyro_3d_probe(struct platform_device *pdev)
> return ret;
> }
>
> - channels = kmemdup(gyro_3d_channels, sizeof(gyro_3d_channels),
> - GFP_KERNEL);
> - if (!channels) {
> + indio_dev->channels = kmemdup(gyro_3d_channels,
> + sizeof(gyro_3d_channels), GFP_KERNEL);
> + if (!indio_dev->channels) {
> dev_err(&pdev->dev, "failed to duplicate channels\n");
> return -ENOMEM;
> }
>
> - ret = gyro_3d_parse_report(pdev, hsdev, channels,
> - HID_USAGE_SENSOR_GYRO_3D, gyro_state);
> + ret = gyro_3d_parse_report(pdev, hsdev,
> + (struct iio_chan_spec *)indio_dev->channels,
> + HID_USAGE_SENSOR_GYRO_3D, gyro_state);
> if (ret) {
> dev_err(&pdev->dev, "failed to setup attributes\n");
> goto error_free_dev_mem;
> }
>
> - indio_dev->channels = channels;
> indio_dev->num_channels = ARRAY_SIZE(gyro_3d_channels);
> indio_dev->dev.parent = &pdev->dev;
> indio_dev->info = &gyro_3d_info;
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v3 3/6] iio: light: hid-sensor-als.c: Fix memory leak in probe()
2015-05-13 18:06 ` [PATCH v3 3/6] iio: light: hid-sensor-als.c: " Fabio Estevam
@ 2015-05-13 18:52 ` Srinivas Pandruvada
2015-05-17 8:11 ` Jonathan Cameron
0 siblings, 1 reply; 18+ messages in thread
From: Srinivas Pandruvada @ 2015-05-13 18:52 UTC (permalink / raw)
To: Fabio Estevam; +Cc: jic23, linux-iio, Fabio Estevam
On Wed, 2015-05-13 at 15:06 -0300, Fabio Estevam wrote:
> From: Fabio Estevam <fabio.estevam@freescale.com>
>
> 'channels' is allocated via kmemdup and it is never freed in the
> subsequent error paths.
>
> Use 'indio_dev->channels' directly instead, so that we avoid such
> memory leak problem.
>
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
Reviewed-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
> ---
> Build-tested only.
>
> Changes since v2:
> - None
> Changes since v1:
> - Make clear in the commit log that the proble only occurs in the error
> paths
>
>
> drivers/iio/light/hid-sensor-als.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/iio/light/hid-sensor-als.c b/drivers/iio/light/hid-sensor-als.c
> index 1609ecd..9d74364 100644
> --- a/drivers/iio/light/hid-sensor-als.c
> +++ b/drivers/iio/light/hid-sensor-als.c
> @@ -263,7 +263,6 @@ static int hid_als_probe(struct platform_device *pdev)
> struct iio_dev *indio_dev;
> struct als_state *als_state;
> struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data;
> - struct iio_chan_spec *channels;
>
> indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(struct als_state));
> if (!indio_dev)
> @@ -281,20 +280,21 @@ static int hid_als_probe(struct platform_device *pdev)
> return ret;
> }
>
> - channels = kmemdup(als_channels, sizeof(als_channels), GFP_KERNEL);
> - if (!channels) {
> + indio_dev->channels = kmemdup(als_channels,
> + sizeof(als_channels), GFP_KERNEL);
> + if (!indio_dev->channels) {
> dev_err(&pdev->dev, "failed to duplicate channels\n");
> return -ENOMEM;
> }
>
> - ret = als_parse_report(pdev, hsdev, channels,
> - HID_USAGE_SENSOR_ALS, als_state);
> + ret = als_parse_report(pdev, hsdev,
> + (struct iio_chan_spec *)indio_dev->channels,
> + HID_USAGE_SENSOR_ALS, als_state);
> if (ret) {
> dev_err(&pdev->dev, "failed to setup attributes\n");
> goto error_free_dev_mem;
> }
>
> - indio_dev->channels = channels;
> indio_dev->num_channels =
> ARRAY_SIZE(als_channels);
> indio_dev->dev.parent = &pdev->dev;
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v3 4/6] iio: orientation: hid-sensor-incl-3d: Fix memory leak in probe()
2015-05-13 18:06 ` [PATCH v3 4/6] iio: orientation: hid-sensor-incl-3d: " Fabio Estevam
@ 2015-05-13 18:54 ` Srinivas Pandruvada
2015-05-17 8:11 ` Jonathan Cameron
0 siblings, 1 reply; 18+ messages in thread
From: Srinivas Pandruvada @ 2015-05-13 18:54 UTC (permalink / raw)
To: Fabio Estevam; +Cc: jic23, linux-iio, Fabio Estevam
On Wed, 2015-05-13 at 15:06 -0300, Fabio Estevam wrote:
> From: Fabio Estevam <fabio.estevam@freescale.com>
>
> 'channels' is allocated via kmemdup and it is never freed in the
> subsequent error paths.
>
> Use 'indio_dev->channels' directly instead, so that we avoid such
> memory leak problem.
>
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
Reviewed-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
> ---
> Build-tested only.
>
> Changes since v2:
> - None
> Changes since v1:
> - Make clear in the commit log that the proble only occurs in the error
> paths
>
> drivers/iio/orientation/hid-sensor-incl-3d.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/iio/orientation/hid-sensor-incl-3d.c b/drivers/iio/orientation/hid-sensor-incl-3d.c
> index 5930fa3..2eb49a8 100644
> --- a/drivers/iio/orientation/hid-sensor-incl-3d.c
> +++ b/drivers/iio/orientation/hid-sensor-incl-3d.c
> @@ -315,7 +315,6 @@ static int hid_incl_3d_probe(struct platform_device *pdev)
> struct iio_dev *indio_dev;
> struct incl_3d_state *incl_state;
> struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data;
> - struct iio_chan_spec *channels;
>
> indio_dev = devm_iio_device_alloc(&pdev->dev,
> sizeof(struct incl_3d_state));
> @@ -336,21 +335,22 @@ static int hid_incl_3d_probe(struct platform_device *pdev)
> return ret;
> }
>
> - channels = kmemdup(incl_3d_channels, sizeof(incl_3d_channels),
> - GFP_KERNEL);
> - if (!channels) {
> + indio_dev->channels = kmemdup(incl_3d_channels,
> + sizeof(incl_3d_channels), GFP_KERNEL);
> + if (!indio_dev->channels) {
> dev_err(&pdev->dev, "failed to duplicate channels\n");
> return -ENOMEM;
> }
>
> - ret = incl_3d_parse_report(pdev, hsdev, channels,
> - HID_USAGE_SENSOR_INCLINOMETER_3D, incl_state);
> + ret = incl_3d_parse_report(pdev, hsdev,
> + (struct iio_chan_spec *)indio_dev->channels,
> + HID_USAGE_SENSOR_INCLINOMETER_3D,
> + incl_state);
> if (ret) {
> dev_err(&pdev->dev, "failed to setup attributes\n");
> goto error_free_dev_mem;
> }
>
> - indio_dev->channels = channels;
> indio_dev->num_channels = ARRAY_SIZE(incl_3d_channels);
> indio_dev->dev.parent = &pdev->dev;
> indio_dev->info = &incl_3d_info;
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v3 5/6] iio: orientation: hid-sensor-rotation: Fix memory leak in probe()
2015-05-13 18:06 ` [PATCH v3 5/6] iio: orientation: hid-sensor-rotation: " Fabio Estevam
@ 2015-05-13 19:03 ` Srinivas Pandruvada
2015-05-17 8:11 ` Jonathan Cameron
0 siblings, 1 reply; 18+ messages in thread
From: Srinivas Pandruvada @ 2015-05-13 19:03 UTC (permalink / raw)
To: Fabio Estevam; +Cc: jic23, linux-iio, Fabio Estevam
On Wed, 2015-05-13 at 15:06 -0300, Fabio Estevam wrote:
> From: Fabio Estevam <fabio.estevam@freescale.com>
>
> 'channels' is allocated via kmemdup and it is never freed in the
> subsequent error paths.
>
> Use 'indio_dev->channels' directly instead, so that we avoid such
> memory leak problem.
>
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
Reviewed-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
> ---
> Build-tested only.
>
> Changes since v2:
> - None
> Changes since v1:
> - Make clear in the commit log that the proble only occurs in the error
> paths
>
> drivers/iio/orientation/hid-sensor-rotation.c | 15 ++++++++-------
> 1 file changed, 8 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/iio/orientation/hid-sensor-rotation.c b/drivers/iio/orientation/hid-sensor-rotation.c
> index 4afb6c7..b6ee50f 100644
> --- a/drivers/iio/orientation/hid-sensor-rotation.c
> +++ b/drivers/iio/orientation/hid-sensor-rotation.c
> @@ -222,7 +222,6 @@ static int hid_dev_rot_probe(struct platform_device *pdev)
> struct iio_dev *indio_dev;
> struct dev_rot_state *rot_state;
> struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data;
> - struct iio_chan_spec *channels;
>
> indio_dev = devm_iio_device_alloc(&pdev->dev,
> sizeof(struct dev_rot_state));
> @@ -243,21 +242,23 @@ static int hid_dev_rot_probe(struct platform_device *pdev)
> return ret;
> }
>
> - channels = devm_kmemdup(&pdev->dev, dev_rot_channels,
> - sizeof(dev_rot_channels), GFP_KERNEL);
> - if (!channels) {
> + indio_dev->channels = devm_kmemdup(&pdev->dev, dev_rot_channels,
> + sizeof(dev_rot_channels),
> + GFP_KERNEL);
> + if (!indio_dev->channels) {
> dev_err(&pdev->dev, "failed to duplicate channels\n");
> return -ENOMEM;
> }
>
> - ret = dev_rot_parse_report(pdev, hsdev, channels,
> - HID_USAGE_SENSOR_DEVICE_ORIENTATION, rot_state);
> + ret = dev_rot_parse_report(pdev, hsdev,
> + (struct iio_chan_spec *)indio_dev->channels,
> + HID_USAGE_SENSOR_DEVICE_ORIENTATION,
> + rot_state);
> if (ret) {
> dev_err(&pdev->dev, "failed to setup attributes\n");
> return ret;
> }
>
> - indio_dev->channels = channels;
> indio_dev->num_channels = ARRAY_SIZE(dev_rot_channels);
> indio_dev->dev.parent = &pdev->dev;
> indio_dev->info = &dev_rot_info;
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v3 6/6] iio: pressure: hid-sensor-press: Fix memory leak in probe()
2015-05-13 18:06 ` [PATCH v3 6/6] iio: pressure: hid-sensor-press: " Fabio Estevam
@ 2015-05-13 19:03 ` Srinivas Pandruvada
2015-05-17 8:11 ` Jonathan Cameron
0 siblings, 1 reply; 18+ messages in thread
From: Srinivas Pandruvada @ 2015-05-13 19:03 UTC (permalink / raw)
To: Fabio Estevam; +Cc: jic23, linux-iio, Fabio Estevam
On Wed, 2015-05-13 at 15:06 -0300, Fabio Estevam wrote:
> From: Fabio Estevam <fabio.estevam@freescale.com>
>
> 'channels' is allocated via kmemdup and it is never freed in the
> subsequent error paths.
>
> Use 'indio_dev->channels' directly instead, so that we avoid such
> memory leak problem.
>
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
Reviewed-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
> ---
> Build-tested only.
>
> Changes since v2:
> - Properly align "press_parse_report(" in multiple lines
> Changes since v1:
> - Make clear in the commit log that the proble only occurs in the error
> paths
> drivers/iio/pressure/hid-sensor-press.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/iio/pressure/hid-sensor-press.c b/drivers/iio/pressure/hid-sensor-press.c
> index 7bb8d4c..5a10dbc 100644
> --- a/drivers/iio/pressure/hid-sensor-press.c
> +++ b/drivers/iio/pressure/hid-sensor-press.c
> @@ -262,7 +262,6 @@ static int hid_press_probe(struct platform_device *pdev)
> struct iio_dev *indio_dev;
> struct press_state *press_state;
> struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data;
> - struct iio_chan_spec *channels;
>
> indio_dev = devm_iio_device_alloc(&pdev->dev,
> sizeof(struct press_state));
> @@ -282,20 +281,21 @@ static int hid_press_probe(struct platform_device *pdev)
> return ret;
> }
>
> - channels = kmemdup(press_channels, sizeof(press_channels), GFP_KERNEL);
> - if (!channels) {
> + indio_dev->channels = kmemdup(press_channels, sizeof(press_channels),
> + GFP_KERNEL);
> + if (!indio_dev->channels) {
> dev_err(&pdev->dev, "failed to duplicate channels\n");
> return -ENOMEM;
> }
>
> - ret = press_parse_report(pdev, hsdev, channels,
> - HID_USAGE_SENSOR_PRESSURE, press_state);
> + ret = press_parse_report(pdev, hsdev,
> + (struct iio_chan_spec *)indio_dev->channels,
> + HID_USAGE_SENSOR_PRESSURE, press_state);
> if (ret) {
> dev_err(&pdev->dev, "failed to setup attributes\n");
> goto error_free_dev_mem;
> }
>
> - indio_dev->channels = channels;
> indio_dev->num_channels =
> ARRAY_SIZE(press_channels);
> indio_dev->dev.parent = &pdev->dev;
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v3 1/6] iio: accel: hid-sensor-accel-3d: Fix memory leak in probe()
2015-05-13 18:51 ` [PATCH v3 1/6] iio: accel: hid-sensor-accel-3d: " Srinivas Pandruvada
@ 2015-05-17 8:09 ` Jonathan Cameron
0 siblings, 0 replies; 18+ messages in thread
From: Jonathan Cameron @ 2015-05-17 8:09 UTC (permalink / raw)
To: Srinivas Pandruvada, Fabio Estevam; +Cc: linux-iio, Fabio Estevam
On 13/05/15 19:51, Srinivas Pandruvada wrote:
> On Wed, 2015-05-13 at 15:06 -0300, Fabio Estevam wrote:
>> From: Fabio Estevam <fabio.estevam@freescale.com>
>>
>> 'channels' is allocated via kmemdup and it is never freed in the
>> subsequent error paths.
>>
>> Use 'indio_dev->channels' directly instead, so that we avoid such
>> memory leak problem.
>>
>> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> Reviewed-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Applied to the togreg branch of iio.git
Thanks,
>> ---
>> Build-tested only.
>>
>> Changes since v2:
>> - Properly align "accel_3d_parse_report(" in multiple lines
>> Changes since v1:
>> - Make clear in the commit log that the proble only occurs in the error
>> paths
>>
>> drivers/iio/accel/hid-sensor-accel-3d.c | 13 ++++++-------
>> 1 file changed, 6 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/iio/accel/hid-sensor-accel-3d.c b/drivers/iio/accel/hid-sensor-accel-3d.c
>> index 2b4fad6..b933957 100644
>> --- a/drivers/iio/accel/hid-sensor-accel-3d.c
>> +++ b/drivers/iio/accel/hid-sensor-accel-3d.c
>> @@ -299,7 +299,6 @@ static int hid_accel_3d_probe(struct platform_device *pdev)
>> struct iio_dev *indio_dev;
>> struct accel_3d_state *accel_state;
>> struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data;
>> - struct iio_chan_spec *channels;
>>
>> indio_dev = devm_iio_device_alloc(&pdev->dev,
>> sizeof(struct accel_3d_state));
>> @@ -320,21 +319,21 @@ static int hid_accel_3d_probe(struct platform_device *pdev)
>> return ret;
>> }
>>
>> - channels = kmemdup(accel_3d_channels, sizeof(accel_3d_channels),
>> - GFP_KERNEL);
>> - if (!channels) {
>> + indio_dev->channels = kmemdup(accel_3d_channels,
>> + sizeof(accel_3d_channels), GFP_KERNEL);
>> + if (!indio_dev->channels) {
>> dev_err(&pdev->dev, "failed to duplicate channels\n");
>> return -ENOMEM;
>> }
>>
>> - ret = accel_3d_parse_report(pdev, hsdev, channels,
>> - HID_USAGE_SENSOR_ACCEL_3D, accel_state);
>> + ret = accel_3d_parse_report(pdev, hsdev,
>> + (struct iio_chan_spec *)indio_dev->channels,
>> + HID_USAGE_SENSOR_ACCEL_3D, accel_state);
>> if (ret) {
>> dev_err(&pdev->dev, "failed to setup attributes\n");
>> goto error_free_dev_mem;
>> }
>>
>> - indio_dev->channels = channels;
>> indio_dev->num_channels = ARRAY_SIZE(accel_3d_channels);
>> indio_dev->dev.parent = &pdev->dev;
>> indio_dev->info = &accel_3d_info;
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v3 2/6] iio: gyro: hid-sensor-gyro-3d: Fix memory leak in probe()
2015-05-13 18:52 ` Srinivas Pandruvada
@ 2015-05-17 8:10 ` Jonathan Cameron
0 siblings, 0 replies; 18+ messages in thread
From: Jonathan Cameron @ 2015-05-17 8:10 UTC (permalink / raw)
To: Srinivas Pandruvada, Fabio Estevam; +Cc: linux-iio, Fabio Estevam
On 13/05/15 19:52, Srinivas Pandruvada wrote:
> On Wed, 2015-05-13 at 15:06 -0300, Fabio Estevam wrote:
>> From: Fabio Estevam <fabio.estevam@freescale.com>
>>
>> 'channels' is allocated via kmemdup and it is never freed in the
>> subsequent error paths.
>>
>> Use 'indio_dev->channels' directly instead, so that we avoid such
>> memory leak problem.
>>
>> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> Reviewed-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Applied.
>> ---
>> Build-tested only.
>>
>> Changes since v2:
>> - None
>> Changes since v1:
>> - Make clear in the commit log that the proble only occurs in the error
>> paths
>>
>> drivers/iio/gyro/hid-sensor-gyro-3d.c | 13 ++++++-------
>> 1 file changed, 6 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/iio/gyro/hid-sensor-gyro-3d.c b/drivers/iio/gyro/hid-sensor-gyro-3d.c
>> index b5883b6..7b60b58 100644
>> --- a/drivers/iio/gyro/hid-sensor-gyro-3d.c
>> +++ b/drivers/iio/gyro/hid-sensor-gyro-3d.c
>> @@ -298,7 +298,6 @@ static int hid_gyro_3d_probe(struct platform_device *pdev)
>> struct iio_dev *indio_dev;
>> struct gyro_3d_state *gyro_state;
>> struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data;
>> - struct iio_chan_spec *channels;
>>
>> indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*gyro_state));
>> if (!indio_dev)
>> @@ -317,21 +316,21 @@ static int hid_gyro_3d_probe(struct platform_device *pdev)
>> return ret;
>> }
>>
>> - channels = kmemdup(gyro_3d_channels, sizeof(gyro_3d_channels),
>> - GFP_KERNEL);
>> - if (!channels) {
>> + indio_dev->channels = kmemdup(gyro_3d_channels,
>> + sizeof(gyro_3d_channels), GFP_KERNEL);
>> + if (!indio_dev->channels) {
>> dev_err(&pdev->dev, "failed to duplicate channels\n");
>> return -ENOMEM;
>> }
>>
>> - ret = gyro_3d_parse_report(pdev, hsdev, channels,
>> - HID_USAGE_SENSOR_GYRO_3D, gyro_state);
>> + ret = gyro_3d_parse_report(pdev, hsdev,
>> + (struct iio_chan_spec *)indio_dev->channels,
>> + HID_USAGE_SENSOR_GYRO_3D, gyro_state);
>> if (ret) {
>> dev_err(&pdev->dev, "failed to setup attributes\n");
>> goto error_free_dev_mem;
>> }
>>
>> - indio_dev->channels = channels;
>> indio_dev->num_channels = ARRAY_SIZE(gyro_3d_channels);
>> indio_dev->dev.parent = &pdev->dev;
>> indio_dev->info = &gyro_3d_info;
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v3 3/6] iio: light: hid-sensor-als.c: Fix memory leak in probe()
2015-05-13 18:52 ` Srinivas Pandruvada
@ 2015-05-17 8:11 ` Jonathan Cameron
0 siblings, 0 replies; 18+ messages in thread
From: Jonathan Cameron @ 2015-05-17 8:11 UTC (permalink / raw)
To: Srinivas Pandruvada, Fabio Estevam; +Cc: linux-iio, Fabio Estevam
On 13/05/15 19:52, Srinivas Pandruvada wrote:
> On Wed, 2015-05-13 at 15:06 -0300, Fabio Estevam wrote:
>> From: Fabio Estevam <fabio.estevam@freescale.com>
>>
>> 'channels' is allocated via kmemdup and it is never freed in the
>> subsequent error paths.
>>
>> Use 'indio_dev->channels' directly instead, so that we avoid such
>> memory leak problem.
>>
>> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> Reviewed-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Applied to the togreg branch of iio.git - initially pushed out as testing.
Thanks.
>> ---
>> Build-tested only.
>>
>> Changes since v2:
>> - None
>> Changes since v1:
>> - Make clear in the commit log that the proble only occurs in the error
>> paths
>>
>>
>> drivers/iio/light/hid-sensor-als.c | 12 ++++++------
>> 1 file changed, 6 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/iio/light/hid-sensor-als.c b/drivers/iio/light/hid-sensor-als.c
>> index 1609ecd..9d74364 100644
>> --- a/drivers/iio/light/hid-sensor-als.c
>> +++ b/drivers/iio/light/hid-sensor-als.c
>> @@ -263,7 +263,6 @@ static int hid_als_probe(struct platform_device *pdev)
>> struct iio_dev *indio_dev;
>> struct als_state *als_state;
>> struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data;
>> - struct iio_chan_spec *channels;
>>
>> indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(struct als_state));
>> if (!indio_dev)
>> @@ -281,20 +280,21 @@ static int hid_als_probe(struct platform_device *pdev)
>> return ret;
>> }
>>
>> - channels = kmemdup(als_channels, sizeof(als_channels), GFP_KERNEL);
>> - if (!channels) {
>> + indio_dev->channels = kmemdup(als_channels,
>> + sizeof(als_channels), GFP_KERNEL);
>> + if (!indio_dev->channels) {
>> dev_err(&pdev->dev, "failed to duplicate channels\n");
>> return -ENOMEM;
>> }
>>
>> - ret = als_parse_report(pdev, hsdev, channels,
>> - HID_USAGE_SENSOR_ALS, als_state);
>> + ret = als_parse_report(pdev, hsdev,
>> + (struct iio_chan_spec *)indio_dev->channels,
>> + HID_USAGE_SENSOR_ALS, als_state);
>> if (ret) {
>> dev_err(&pdev->dev, "failed to setup attributes\n");
>> goto error_free_dev_mem;
>> }
>>
>> - indio_dev->channels = channels;
>> indio_dev->num_channels =
>> ARRAY_SIZE(als_channels);
>> indio_dev->dev.parent = &pdev->dev;
>
>
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v3 4/6] iio: orientation: hid-sensor-incl-3d: Fix memory leak in probe()
2015-05-13 18:54 ` Srinivas Pandruvada
@ 2015-05-17 8:11 ` Jonathan Cameron
0 siblings, 0 replies; 18+ messages in thread
From: Jonathan Cameron @ 2015-05-17 8:11 UTC (permalink / raw)
To: Srinivas Pandruvada, Fabio Estevam; +Cc: linux-iio, Fabio Estevam
On 13/05/15 19:54, Srinivas Pandruvada wrote:
> On Wed, 2015-05-13 at 15:06 -0300, Fabio Estevam wrote:
>> From: Fabio Estevam <fabio.estevam@freescale.com>
>>
>> 'channels' is allocated via kmemdup and it is never freed in the
>> subsequent error paths.
>>
>> Use 'indio_dev->channels' directly instead, so that we avoid such
>> memory leak problem.
>>
>> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> Reviewed-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Applied to the togreg branch of iio.git - initially pushed out as testing.
Thanks.
>> ---
>> Build-tested only.
>>
>> Changes since v2:
>> - None
>> Changes since v1:
>> - Make clear in the commit log that the proble only occurs in the error
>> paths
>>
>> drivers/iio/orientation/hid-sensor-incl-3d.c | 14 +++++++-------
>> 1 file changed, 7 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/iio/orientation/hid-sensor-incl-3d.c b/drivers/iio/orientation/hid-sensor-incl-3d.c
>> index 5930fa3..2eb49a8 100644
>> --- a/drivers/iio/orientation/hid-sensor-incl-3d.c
>> +++ b/drivers/iio/orientation/hid-sensor-incl-3d.c
>> @@ -315,7 +315,6 @@ static int hid_incl_3d_probe(struct platform_device *pdev)
>> struct iio_dev *indio_dev;
>> struct incl_3d_state *incl_state;
>> struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data;
>> - struct iio_chan_spec *channels;
>>
>> indio_dev = devm_iio_device_alloc(&pdev->dev,
>> sizeof(struct incl_3d_state));
>> @@ -336,21 +335,22 @@ static int hid_incl_3d_probe(struct platform_device *pdev)
>> return ret;
>> }
>>
>> - channels = kmemdup(incl_3d_channels, sizeof(incl_3d_channels),
>> - GFP_KERNEL);
>> - if (!channels) {
>> + indio_dev->channels = kmemdup(incl_3d_channels,
>> + sizeof(incl_3d_channels), GFP_KERNEL);
>> + if (!indio_dev->channels) {
>> dev_err(&pdev->dev, "failed to duplicate channels\n");
>> return -ENOMEM;
>> }
>>
>> - ret = incl_3d_parse_report(pdev, hsdev, channels,
>> - HID_USAGE_SENSOR_INCLINOMETER_3D, incl_state);
>> + ret = incl_3d_parse_report(pdev, hsdev,
>> + (struct iio_chan_spec *)indio_dev->channels,
>> + HID_USAGE_SENSOR_INCLINOMETER_3D,
>> + incl_state);
>> if (ret) {
>> dev_err(&pdev->dev, "failed to setup attributes\n");
>> goto error_free_dev_mem;
>> }
>>
>> - indio_dev->channels = channels;
>> indio_dev->num_channels = ARRAY_SIZE(incl_3d_channels);
>> indio_dev->dev.parent = &pdev->dev;
>> indio_dev->info = &incl_3d_info;
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v3 5/6] iio: orientation: hid-sensor-rotation: Fix memory leak in probe()
2015-05-13 19:03 ` Srinivas Pandruvada
@ 2015-05-17 8:11 ` Jonathan Cameron
0 siblings, 0 replies; 18+ messages in thread
From: Jonathan Cameron @ 2015-05-17 8:11 UTC (permalink / raw)
To: Srinivas Pandruvada, Fabio Estevam; +Cc: linux-iio, Fabio Estevam
On 13/05/15 20:03, Srinivas Pandruvada wrote:
> On Wed, 2015-05-13 at 15:06 -0300, Fabio Estevam wrote:
>> From: Fabio Estevam <fabio.estevam@freescale.com>
>>
>> 'channels' is allocated via kmemdup and it is never freed in the
>> subsequent error paths.
>>
>> Use 'indio_dev->channels' directly instead, so that we avoid such
>> memory leak problem.
>>
>> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> Reviewed-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Applied to the togreg branch of iio.git - initially pushed out as testing.
Thanks.
>> ---
>> Build-tested only.
>>
>> Changes since v2:
>> - None
>> Changes since v1:
>> - Make clear in the commit log that the proble only occurs in the error
>> paths
>>
>> drivers/iio/orientation/hid-sensor-rotation.c | 15 ++++++++-------
>> 1 file changed, 8 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/iio/orientation/hid-sensor-rotation.c b/drivers/iio/orientation/hid-sensor-rotation.c
>> index 4afb6c7..b6ee50f 100644
>> --- a/drivers/iio/orientation/hid-sensor-rotation.c
>> +++ b/drivers/iio/orientation/hid-sensor-rotation.c
>> @@ -222,7 +222,6 @@ static int hid_dev_rot_probe(struct platform_device *pdev)
>> struct iio_dev *indio_dev;
>> struct dev_rot_state *rot_state;
>> struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data;
>> - struct iio_chan_spec *channels;
>>
>> indio_dev = devm_iio_device_alloc(&pdev->dev,
>> sizeof(struct dev_rot_state));
>> @@ -243,21 +242,23 @@ static int hid_dev_rot_probe(struct platform_device *pdev)
>> return ret;
>> }
>>
>> - channels = devm_kmemdup(&pdev->dev, dev_rot_channels,
>> - sizeof(dev_rot_channels), GFP_KERNEL);
>> - if (!channels) {
>> + indio_dev->channels = devm_kmemdup(&pdev->dev, dev_rot_channels,
>> + sizeof(dev_rot_channels),
>> + GFP_KERNEL);
>> + if (!indio_dev->channels) {
>> dev_err(&pdev->dev, "failed to duplicate channels\n");
>> return -ENOMEM;
>> }
>>
>> - ret = dev_rot_parse_report(pdev, hsdev, channels,
>> - HID_USAGE_SENSOR_DEVICE_ORIENTATION, rot_state);
>> + ret = dev_rot_parse_report(pdev, hsdev,
>> + (struct iio_chan_spec *)indio_dev->channels,
>> + HID_USAGE_SENSOR_DEVICE_ORIENTATION,
>> + rot_state);
>> if (ret) {
>> dev_err(&pdev->dev, "failed to setup attributes\n");
>> return ret;
>> }
>>
>> - indio_dev->channels = channels;
>> indio_dev->num_channels = ARRAY_SIZE(dev_rot_channels);
>> indio_dev->dev.parent = &pdev->dev;
>> indio_dev->info = &dev_rot_info;
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v3 6/6] iio: pressure: hid-sensor-press: Fix memory leak in probe()
2015-05-13 19:03 ` Srinivas Pandruvada
@ 2015-05-17 8:11 ` Jonathan Cameron
0 siblings, 0 replies; 18+ messages in thread
From: Jonathan Cameron @ 2015-05-17 8:11 UTC (permalink / raw)
To: Srinivas Pandruvada, Fabio Estevam; +Cc: linux-iio, Fabio Estevam
On 13/05/15 20:03, Srinivas Pandruvada wrote:
> On Wed, 2015-05-13 at 15:06 -0300, Fabio Estevam wrote:
>> From: Fabio Estevam <fabio.estevam@freescale.com>
>>
>> 'channels' is allocated via kmemdup and it is never freed in the
>> subsequent error paths.
>>
>> Use 'indio_dev->channels' directly instead, so that we avoid such
>> memory leak problem.
>>
>> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> Reviewed-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Applied to the togreg branch of iio.git - initially pushed out as testing.
Thanks.
>> ---
>> Build-tested only.
>>
>> Changes since v2:
>> - Properly align "press_parse_report(" in multiple lines
>> Changes since v1:
>> - Make clear in the commit log that the proble only occurs in the error
>> paths
>> drivers/iio/pressure/hid-sensor-press.c | 12 ++++++------
>> 1 file changed, 6 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/iio/pressure/hid-sensor-press.c b/drivers/iio/pressure/hid-sensor-press.c
>> index 7bb8d4c..5a10dbc 100644
>> --- a/drivers/iio/pressure/hid-sensor-press.c
>> +++ b/drivers/iio/pressure/hid-sensor-press.c
>> @@ -262,7 +262,6 @@ static int hid_press_probe(struct platform_device *pdev)
>> struct iio_dev *indio_dev;
>> struct press_state *press_state;
>> struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data;
>> - struct iio_chan_spec *channels;
>>
>> indio_dev = devm_iio_device_alloc(&pdev->dev,
>> sizeof(struct press_state));
>> @@ -282,20 +281,21 @@ static int hid_press_probe(struct platform_device *pdev)
>> return ret;
>> }
>>
>> - channels = kmemdup(press_channels, sizeof(press_channels), GFP_KERNEL);
>> - if (!channels) {
>> + indio_dev->channels = kmemdup(press_channels, sizeof(press_channels),
>> + GFP_KERNEL);
>> + if (!indio_dev->channels) {
>> dev_err(&pdev->dev, "failed to duplicate channels\n");
>> return -ENOMEM;
>> }
>>
>> - ret = press_parse_report(pdev, hsdev, channels,
>> - HID_USAGE_SENSOR_PRESSURE, press_state);
>> + ret = press_parse_report(pdev, hsdev,
>> + (struct iio_chan_spec *)indio_dev->channels,
>> + HID_USAGE_SENSOR_PRESSURE, press_state);
>> if (ret) {
>> dev_err(&pdev->dev, "failed to setup attributes\n");
>> goto error_free_dev_mem;
>> }
>>
>> - indio_dev->channels = channels;
>> indio_dev->num_channels =
>> ARRAY_SIZE(press_channels);
>> indio_dev->dev.parent = &pdev->dev;
>
>
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2015-05-17 8:11 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-13 18:06 [PATCH v3 1/6] iio: accel: hid-sensor-accel-3d: Fix memory leak in probe() Fabio Estevam
2015-05-13 18:06 ` [PATCH v3 2/6] iio: gyro: hid-sensor-gyro-3d: " Fabio Estevam
2015-05-13 18:52 ` Srinivas Pandruvada
2015-05-17 8:10 ` Jonathan Cameron
2015-05-13 18:06 ` [PATCH v3 3/6] iio: light: hid-sensor-als.c: " Fabio Estevam
2015-05-13 18:52 ` Srinivas Pandruvada
2015-05-17 8:11 ` Jonathan Cameron
2015-05-13 18:06 ` [PATCH v3 4/6] iio: orientation: hid-sensor-incl-3d: " Fabio Estevam
2015-05-13 18:54 ` Srinivas Pandruvada
2015-05-17 8:11 ` Jonathan Cameron
2015-05-13 18:06 ` [PATCH v3 5/6] iio: orientation: hid-sensor-rotation: " Fabio Estevam
2015-05-13 19:03 ` Srinivas Pandruvada
2015-05-17 8:11 ` Jonathan Cameron
2015-05-13 18:06 ` [PATCH v3 6/6] iio: pressure: hid-sensor-press: " Fabio Estevam
2015-05-13 19:03 ` Srinivas Pandruvada
2015-05-17 8:11 ` Jonathan Cameron
2015-05-13 18:51 ` [PATCH v3 1/6] iio: accel: hid-sensor-accel-3d: " Srinivas Pandruvada
2015-05-17 8:09 ` Jonathan Cameron
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.