iio: hid-sensor: Return proper error if kmemdup fails
authorAxel Lin <axel.lin@ingics.com>
Sat, 27 Oct 2012 15:03:00 +0000 (16:03 +0100)
committerJonathan Cameron <jic23@kernel.org>
Sat, 17 Nov 2012 10:17:28 +0000 (10:17 +0000)
Return -ENOMEM instead of 0 if kmemdup fails.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/iio/accel/hid-sensor-accel-3d.c
drivers/iio/gyro/hid-sensor-gyro-3d.c
drivers/iio/light/hid-sensor-als.c
drivers/iio/magnetometer/hid-sensor-magn-3d.c

index a95cda0e387f6c2781fa663bd020211693671d57..e67bb912bd197b90de0cfccfda2a50041325c52f 100644 (file)
@@ -306,10 +306,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;
        }
index 02ef989b830d2d897ba580c8cc3c3305b06ba31b..4c8b158e40e18d508d4dfd53d7108249e2f2a455 100644 (file)
@@ -306,10 +306,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;
        }
index 8e1f69844eea796da357ac67aded7959a7c70557..23eeeef64e84b93e656ccb07a21dfd57c90a8190 100644 (file)
@@ -272,10 +272,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;
        }
index d1b5fb74b9bf1b92091287223f2cd0e8a28e5882..8e75eb76ccd992729785c340e7eaea801026ec89 100644 (file)
@@ -307,10 +307,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;
        }