2018-02-10 20:32:26

by SF Markus Elfring

[permalink] [raw]
Subject: [PATCH 0/2] GPIO-Timberdale: Adjustments for timbgpio_probe()

From: Markus Elfring <[email protected]>
Date: Sat, 10 Feb 2018 21:28:29 +0100

Two update suggestions were taken into account
from static source code analysis.

Markus Elfring (2):
Delete an error message for a failed memory allocation
Improve a size determination

drivers/gpio/gpio-timberdale.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)

--
2.16.1



2018-02-10 20:33:41

by SF Markus Elfring

[permalink] [raw]
Subject: [PATCH 1/2] gpio: timberdale: Delete an error message for a failed memory allocation in timbgpio_probe()

From: Markus Elfring <[email protected]>
Date: Sat, 10 Feb 2018 21:09:08 +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/gpio/gpio-timberdale.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/gpio/gpio-timberdale.c b/drivers/gpio/gpio-timberdale.c
index 181f86ce00cd..ff155e437210 100644
--- a/drivers/gpio/gpio-timberdale.c
+++ b/drivers/gpio/gpio-timberdale.c
@@ -239,10 +239,9 @@ static int timbgpio_probe(struct platform_device *pdev)
}

tgpio = devm_kzalloc(dev, sizeof(struct timbgpio), GFP_KERNEL);
- if (!tgpio) {
- dev_err(dev, "Memory alloc failed\n");
+ if (!tgpio)
return -EINVAL;
- }
+
tgpio->irq_base = pdata->irq_base;

spin_lock_init(&tgpio->lock);
--
2.16.1


2018-02-10 20:34:50

by SF Markus Elfring

[permalink] [raw]
Subject: [PATCH 2/2] gpio: timberdale: Improve a size determination in timbgpio_probe()

From: Markus Elfring <[email protected]>
Date: Sat, 10 Feb 2018 21:13:28 +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/gpio/gpio-timberdale.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio-timberdale.c b/drivers/gpio/gpio-timberdale.c
index ff155e437210..6520a8475910 100644
--- a/drivers/gpio/gpio-timberdale.c
+++ b/drivers/gpio/gpio-timberdale.c
@@ -238,7 +238,7 @@ static int timbgpio_probe(struct platform_device *pdev)
return -EINVAL;
}

- tgpio = devm_kzalloc(dev, sizeof(struct timbgpio), GFP_KERNEL);
+ tgpio = devm_kzalloc(dev, sizeof(*tgpio), GFP_KERNEL);
if (!tgpio)
return -EINVAL;

--
2.16.1


2018-02-22 14:16:23

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH 1/2] gpio: timberdale: Delete an error message for a failed memory allocation in timbgpio_probe()

On Sat, Feb 10, 2018 at 9:32 PM, SF Markus Elfring
<[email protected]> wrote:

> From: Markus Elfring <[email protected]>
> Date: Sat, 10 Feb 2018 21:09:08 +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]>

Patch applied.

Yours,
Linus Walleij

2018-02-22 14:16:57

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH 2/2] gpio: timberdale: Improve a size determination in timbgpio_probe()

On Sat, Feb 10, 2018 at 9:33 PM, SF Markus Elfring
<[email protected]> wrote:

> From: Markus Elfring <[email protected]>
> Date: Sat, 10 Feb 2018 21:13:28 +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]>

Patch applied.

Yours,
Linus Walleij