iio: accel: hid-sensor-accel-3d: Fix memory leak in probe()
Subsystems (2)
PATCH v3 1/6 iio: accel: hid-sensor-accel-3d: Fix memory leak in probe()
From: Fabio Estevam <[email protected]>
'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.
---
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(-)
drivers/iio/accel/hid-sensor-accel-3d.c +6 -7
@@ -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;
Signature · 1 line
1.9.1
PATCH v3 2/6 iio: gyro: hid-sensor-gyro-3d: Fix memory leak in probe()
From: Fabio Estevam <[email protected]>
'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.
---
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(-)
drivers/iio/gyro/hid-sensor-gyro-3d.c +6 -7
@@ -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;
Signature · 1 line
1.9.1
Re: [PATCH v3 2/6] iio: gyro: hid-sensor-gyro-3d: Fix memory leak in probe()
Quoted 9 lines · Fabio Estevam
From: Fabio Estevam <[email protected]>
'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 <[email protected]>
Quoted 52 lines
---
Build-tested only.Changes since v2:
- None
Changes since v1:
- Make clear in the commit log that the proble only occurs in the error pathsdrivers/iio/gyro/hid-sensor-gyro-3d.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)drivers/iio/gyro/hid-sensor-gyro-3d.c +6
-7@@ -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;
Re: [PATCH v3 2/6] iio: gyro: hid-sensor-gyro-3d: Fix memory leak in probe()
Quoted 11 lines · Srinivas Pandruvada
Quoted 9 lines · Fabio Estevam
From: Fabio Estevam <[email protected]>
'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 <[email protected]>Reviewed-by Srinivas Pandruvada <[email protected]>
Applied.
Quoted 59 lines
Quoted 42 lines
---
Build-tested only.Changes since v2:
- None
Changes since v1:
- Make clear in the commit log that the proble only occurs in the error pathsdrivers/iio/gyro/hid-sensor-gyro-3d.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)drivers/iio/gyro/hid-sensor-gyro-3d.c +5
-6@@ -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,drivers/iio/gyro/hid-sensor-gyro-3d.c static int hid_gyro_3d_probe(struct platform_device *pdev) · line 336
Quoted 10 lines
drivers/iio/gyro/hid-sensor-gyro-3d.c +1
-1+ 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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v3 3/6 iio: light: hid-sensor-als.c: Fix memory leak in probe()
In reply to Fabio EstevamFrom: Fabio Estevam <[email protected]>
'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.
---
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(-)
drivers/iio/light/hid-sensor-als.c +6 -6
@@ -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;
Signature · 1 line
1.9.1
Re: [PATCH v3 3/6] iio: light: hid-sensor-als.c: Fix memory leak in probe()
Quoted 9 lines · Fabio Estevam
From: Fabio Estevam <[email protected]>
'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 <[email protected]>
Quoted 52 lines
---
Build-tested only.Changes since v2:
- None
Changes since v1:
- Make clear in the commit log that the proble only occurs in the error pathsdrivers/iio/light/hid-sensor-als.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)drivers/iio/light/hid-sensor-als.c +6
-6@@ -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;
Jonathan Cameron
maintainerRe: [PATCH v3 3/6] iio: light: hid-sensor-als.c: Fix memory leak in probe()
Quoted 11 lines · Srinivas Pandruvada
Quoted 9 lines · Fabio Estevam
From: Fabio Estevam <[email protected]>
'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 <[email protected]>Reviewed-by Srinivas Pandruvada <[email protected]>
Applied to the togreg branch of iio.git - initially pushed out as testing. Thanks.
Quoted 54 lines
Quoted 52 lines
---
Build-tested only.Changes since v2:
- None
Changes since v1:
- Make clear in the commit log that the proble only occurs in the error pathsdrivers/iio/light/hid-sensor-als.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)drivers/iio/light/hid-sensor-als.c +6
-6@@ -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;
PATCH v3 4/6 iio: orientation: hid-sensor-incl-3d: Fix memory leak in probe()
In reply to Fabio EstevamFrom: Fabio Estevam <[email protected]>
'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.
---
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(-)
drivers/iio/orientation/hid-sensor-incl-3d.c +7 -7
@@ -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;
Signature · 1 line
1.9.1
Re: [PATCH v3 4/6] iio: orientation: hid-sensor-incl-3d: Fix memory leak in probe()
Quoted 9 lines · Fabio Estevam
From: Fabio Estevam <[email protected]>
'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 <[email protected]>
Quoted 53 lines
---
Build-tested only.Changes since v2:
- None
Changes since v1:
- Make clear in the commit log that the proble only occurs in the error pathsdrivers/iio/orientation/hid-sensor-incl-3d.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)drivers/iio/orientation/hid-sensor-incl-3d.c +7
-7@@ -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;
Jonathan Cameron
maintainerRe: [PATCH v3 4/6] iio: orientation: hid-sensor-incl-3d: Fix memory leak in probe()
Quoted 11 lines · Srinivas Pandruvada
Quoted 9 lines · Fabio Estevam
From: Fabio Estevam <[email protected]>
'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 <[email protected]>Reviewed-by Srinivas Pandruvada <[email protected]>
Applied to the togreg branch of iio.git - initially pushed out as testing. Thanks.
Quoted 60 lines
Quoted 43 lines
---
Build-tested only.Changes since v2:
- None
Changes since v1:
- Make clear in the commit log that the proble only occurs in the error pathsdrivers/iio/orientation/hid-sensor-incl-3d.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)drivers/iio/orientation/hid-sensor-incl-3d.c +6
-6@@ -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,drivers/iio/orientation/hid-sensor-incl-3d.c static int hid_incl_3d_probe(struct platform_device *pdev) · line 356
Quoted 10 lines
drivers/iio/orientation/hid-sensor-incl-3d.c +1
-1+ 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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v3 5/6 iio: orientation: hid-sensor-rotation: Fix memory leak in probe()
In reply to Fabio EstevamFrom: Fabio Estevam <[email protected]>
'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.
---
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(-)
drivers/iio/orientation/hid-sensor-rotation.c +8 -7
@@ -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;
Signature · 1 line
1.9.1
Re: [PATCH v3 5/6] iio: orientation: hid-sensor-rotation: Fix memory leak in probe()
Quoted 9 lines · Fabio Estevam
From: Fabio Estevam <[email protected]>
'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 <[email protected]>
Quoted 54 lines
---
Build-tested only.Changes since v2:
- None
Changes since v1:
- Make clear in the commit log that the proble only occurs in the error pathsdrivers/iio/orientation/hid-sensor-rotation.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)drivers/iio/orientation/hid-sensor-rotation.c +8
-7@@ -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;
Jonathan Cameron
maintainerRe: [PATCH v3 5/6] iio: orientation: hid-sensor-rotation: Fix memory leak in probe()
Quoted 11 lines · Srinivas Pandruvada
Quoted 9 lines · Fabio Estevam
From: Fabio Estevam <[email protected]>
'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 <[email protected]>Reviewed-by Srinivas Pandruvada <[email protected]>
Applied to the togreg branch of iio.git - initially pushed out as testing. Thanks.
Quoted 61 lines
Quoted 44 lines
---
Build-tested only.Changes since v2:
- None
Changes since v1:
- Make clear in the commit log that the proble only occurs in the error pathsdrivers/iio/orientation/hid-sensor-rotation.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)drivers/iio/orientation/hid-sensor-rotation.c +7
-6@@ -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,drivers/iio/orientation/hid-sensor-rotation.c static int hid_dev_rot_probe(struct platform_device *pdev) · line 264
Quoted 10 lines
drivers/iio/orientation/hid-sensor-rotation.c +1
-1+ 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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v3 6/6 iio: pressure: hid-sensor-press: Fix memory leak in probe()
In reply to Fabio EstevamFrom: Fabio Estevam <[email protected]>
'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.
---
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(-)
drivers/iio/pressure/hid-sensor-press.c +6 -6
@@ -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;
Signature · 1 line
1.9.1
Re: [PATCH v3 6/6] iio: pressure: hid-sensor-press: Fix memory leak in probe()
Quoted 9 lines · Fabio Estevam
From: Fabio Estevam <[email protected]>
'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 <[email protected]>
Quoted 50 lines
---
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 pathsdrivers/iio/pressure/hid-sensor-press.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)drivers/iio/pressure/hid-sensor-press.c +6
-6@@ -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;
Jonathan Cameron
maintainerRe: [PATCH v3 6/6] iio: pressure: hid-sensor-press: Fix memory leak in probe()
Quoted 11 lines · Srinivas Pandruvada
Quoted 9 lines · Fabio Estevam
From: Fabio Estevam <[email protected]>
'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 <[email protected]>Reviewed-by Srinivas Pandruvada <[email protected]>
Applied to the togreg branch of iio.git - initially pushed out as testing. Thanks.
Quoted 52 lines
Quoted 50 lines
---
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 pathsdrivers/iio/pressure/hid-sensor-press.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)drivers/iio/pressure/hid-sensor-press.c +6
-6@@ -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;
Quoted 9 lines · Fabio Estevam
From: Fabio Estevam <[email protected]>
'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 <[email protected]>
Quoted 52 lines
---
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 pathsdrivers/iio/accel/hid-sensor-accel-3d.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)drivers/iio/accel/hid-sensor-accel-3d.c +6
-7@@ -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;
Quoted 11 lines · Srinivas Pandruvada
Quoted 9 lines · Fabio Estevam
From: Fabio Estevam <[email protected]>
'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 <[email protected]>Reviewed-by Srinivas Pandruvada <[email protected]>
Applied to the togreg branch of iio.git
Thanks,
Quoted 59 lines
Quoted 42 lines
---
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 pathsdrivers/iio/accel/hid-sensor-accel-3d.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)drivers/iio/accel/hid-sensor-accel-3d.c +5
-6@@ -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,drivers/iio/accel/hid-sensor-accel-3d.c static int hid_accel_3d_probe(struct platform_device *pdev) · line 339
Quoted 10 lines
drivers/iio/accel/hid-sensor-accel-3d.c +1
-1+ 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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html