From: Markus Elfring <[email protected]>
Date: Tue, 6 Feb 2018 15:38:30 +0100
Three update suggestions were taken into account
from static source code analysis.
Markus Elfring (3):
Delete an error message for a failed memory allocation in lg_probe()
Improve a size determination in lg_probe()
Delete an error message for a failed memory allocation in lg4ff_init()
drivers/hid/hid-lg.c | 7 +++----
drivers/hid/hid-lg4ff.c | 4 +---
2 files changed, 4 insertions(+), 7 deletions(-)
--
2.16.1
From: Markus Elfring <[email protected]>
Date: Tue, 6 Feb 2018 14:25:32 +0100
Omit an extra message for a memory allocation failure in this function.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <[email protected]>
---
drivers/hid/hid-lg.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/hid/hid-lg.c b/drivers/hid/hid-lg.c
index 596227ddb6e0..f4439dc64497 100644
--- a/drivers/hid/hid-lg.c
+++ b/drivers/hid/hid-lg.c
@@ -728,10 +728,9 @@ static int lg_probe(struct hid_device *hdev, const struct hid_device_id *id)
}
drv_data = kzalloc(sizeof(struct lg_drv_data), GFP_KERNEL);
- if (!drv_data) {
- hid_err(hdev, "Insufficient memory, cannot allocate driver data\n");
+ if (!drv_data)
return -ENOMEM;
- }
+
drv_data->quirks = id->driver_data;
hid_set_drvdata(hdev, (void *)drv_data);
--
2.16.1
From: Markus Elfring <[email protected]>
Date: Tue, 6 Feb 2018 14:54:14 +0100
Replace the specification of a data structure by a pointer dereference
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <[email protected]>
---
drivers/hid/hid-lg.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/hid/hid-lg.c b/drivers/hid/hid-lg.c
index f4439dc64497..358b4c6f856d 100644
--- a/drivers/hid/hid-lg.c
+++ b/drivers/hid/hid-lg.c
@@ -727,7 +727,7 @@ static int lg_probe(struct hid_device *hdev, const struct hid_device_id *id)
return -ENODEV;
}
- drv_data = kzalloc(sizeof(struct lg_drv_data), GFP_KERNEL);
+ drv_data = kzalloc(sizeof(*drv_data), GFP_KERNEL);
if (!drv_data)
return -ENOMEM;
--
2.16.1
From: Markus Elfring <[email protected]>
Date: Tue, 6 Feb 2018 15:26:06 +0100
Omit an extra message for a memory allocation failure in this function.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <[email protected]>
---
drivers/hid/hid-lg4ff.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/hid/hid-lg4ff.c b/drivers/hid/hid-lg4ff.c
index 512d67e1aae3..ec6b94bb3fd8 100644
--- a/drivers/hid/hid-lg4ff.c
+++ b/drivers/hid/hid-lg4ff.c
@@ -1401,10 +1401,8 @@ int lg4ff_init(struct hid_device *hid)
for (j = 0; j < 5; j++) {
led = kzalloc(sizeof(struct led_classdev)+name_sz, GFP_KERNEL);
- if (!led) {
- hid_err(hid, "can't allocate memory for LED %d\n", j);
+ if (!led)
goto err_leds;
- }
name = (void *)(&led[1]);
snprintf(name, name_sz, "%s::RPM%d", dev_name(&hid->dev), j+1);
--
2.16.1