iio: hid-sensor: Return proper error if kmemdup fails
Subsystems (2)
PATCH 1/1 iio: hid-sensor: Return proper error if kmemdup fails
Return -ENOMEM instead of 0 if kmemdup fails.
Signed-off-by Axel Lin <[email protected]>
--- drivers/iio/accel/hid-sensor-accel-3d.c | 6 +++--- drivers/iio/gyro/hid-sensor-gyro-3d.c | 6 +++--- drivers/iio/light/hid-sensor-als.c | 5 ++--- drivers/iio/magnetometer/hid-sensor-magn-3d.c | 6 +++--- 4 files changed, 11 insertions(+), 12 deletions(-)
drivers/iio/accel/hid-sensor-accel-3d.c +3 -3
@@ -319,10 +319,10 @@ static int __devinit hid_accel_3d_probe(struct platform_device *pdev) goto error_free_dev; } - channels =kmemdup (accel_3d_channels, -sizeof (accel_3d_channels), -GFP_KERNEL ); + channels =kmemdup (accel_3d_channels,sizeof (accel_3d_channels), +GFP_KERNEL );if (!channels) { + ret = -ENOMEM ;dev_err (&pdev->dev,"failed to duplicate channels\n" ); goto error_free_dev; }
drivers/iio/gyro/hid-sensor-gyro-3d.c +3 -3
@@ -319,10 +319,10 @@ static int __devinit hid_gyro_3d_probe(struct platform_device *pdev) goto error_free_dev; } - channels =kmemdup (gyro_3d_channels, -sizeof (gyro_3d_channels), -GFP_KERNEL ); + channels =kmemdup (gyro_3d_channels,sizeof (gyro_3d_channels), +GFP_KERNEL );if (!channels) { + ret = -ENOMEM ;dev_err (&pdev->dev,"failed to duplicate channels\n" ); goto error_free_dev; }
drivers/iio/light/hid-sensor-als.c +2 -3
@@ -285,10 +285,9 @@ static int __devinit hid_als_probe(struct platform_device *pdev) goto error_free_dev; } - channels =kmemdup (als_channels, -sizeof (als_channels), -GFP_KERNEL ); + channels =kmemdup (als_channels,sizeof (als_channels),GFP_KERNEL );if (!channels) { + ret = -ENOMEM ;dev_err (&pdev->dev,"failed to duplicate channels\n" ); goto error_free_dev; }
drivers/iio/magnetometer/hid-sensor-magn-3d.c +3 -3
@@ -320,10 +320,10 @@ static int __devinit hid_magn_3d_probe(struct platform_device *pdev) goto error_free_dev; } - channels =kmemdup (magn_3d_channels, -sizeof (magn_3d_channels), -GFP_KERNEL ); + channels =kmemdup (magn_3d_channels,sizeof (magn_3d_channels), +GFP_KERNEL );if (!channels) { + ret = -ENOMEM ;dev_err (&pdev->dev,"failed to duplicate channels\n" ); goto error_free_dev; }
Signature · 1 line
1.7.9.5
Jonathan Cameron
maintainerQuoted 3 lines · Axel Lin
Return
-ENOMEMinstead of 0 if kmemdup fails.Signed-off-by Axel Lin <[email protected]>
Added to fixes-togreg branch of iio.git
Thanks
Quoted 79 lines
--- drivers/iio/accel/hid-sensor-accel-3d.c | 6 +++--- drivers/iio/gyro/hid-sensor-gyro-3d.c | 6 +++--- drivers/iio/light/hid-sensor-als.c | 5 ++--- drivers/iio/magnetometer/hid-sensor-magn-3d.c | 6 +++--- 4 files changed, 11 insertions(+), 12 deletions(-)drivers/iio/accel/hid-sensor-accel-3d.c +3
-3@@ -319,10 +319,10 @@ static int __devinit hid_accel_3d_probe(struct platform_device *pdev) goto error_free_dev; } - channels =kmemdup (accel_3d_channels, -sizeof (accel_3d_channels), -GFP_KERNEL ); + channels =kmemdup (accel_3d_channels,sizeof (accel_3d_channels), +GFP_KERNEL );if (!channels) { + ret = -ENOMEM ;dev_err (&pdev->dev,"failed to duplicate channels\n" ); goto error_free_dev; }drivers/iio/gyro/hid-sensor-gyro-3d.c +3
-3@@ -319,10 +319,10 @@ static int __devinit hid_gyro_3d_probe(struct platform_device *pdev) goto error_free_dev; } - channels =kmemdup (gyro_3d_channels, -sizeof (gyro_3d_channels), -GFP_KERNEL ); + channels =kmemdup (gyro_3d_channels,sizeof (gyro_3d_channels), +GFP_KERNEL );if (!channels) { + ret = -ENOMEM ;dev_err (&pdev->dev,"failed to duplicate channels\n" ); goto error_free_dev; }drivers/iio/light/hid-sensor-als.c +2
-3@@ -285,10 +285,9 @@ static int __devinit hid_als_probe(struct platform_device *pdev) goto error_free_dev; } - channels =kmemdup (als_channels, -sizeof (als_channels), -GFP_KERNEL ); + channels =kmemdup (als_channels,sizeof (als_channels),GFP_KERNEL );if (!channels) { + ret = -ENOMEM ;dev_err (&pdev->dev,"failed to duplicate channels\n" ); goto error_free_dev; }drivers/iio/magnetometer/hid-sensor-magn-3d.c +3
-3@@ -320,10 +320,10 @@ static int __devinit hid_magn_3d_probe(struct platform_device *pdev) goto error_free_dev; } - channels =kmemdup (magn_3d_channels, -sizeof (magn_3d_channels), -GFP_KERNEL ); + channels =kmemdup (magn_3d_channels,sizeof (magn_3d_channels), +GFP_KERNEL );if (!channels) { + ret = -ENOMEM ;dev_err (&pdev->dev,"failed to duplicate channels\n" ); goto error_free_dev; }