* [PATCH 0/2] tty-MOXA: Adjustments for moxa_init_board()
@ 2017-12-10 15:30 SF Markus Elfring
2017-12-10 15:31 ` [PATCH 1/2] tty: moxa: Delete an error message for a failed memory allocation in moxa_init_board() SF Markus Elfring
2017-12-10 15:32 ` [PATCH 2/2] tty: moxa: Return directly after a failed kcalloc() " SF Markus Elfring
0 siblings, 2 replies; 3+ messages in thread
From: SF Markus Elfring @ 2017-12-10 15:30 UTC (permalink / raw)
To: kernel-janitors, Greg Kroah-Hartman, Jiri Slaby; +Cc: LKML
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 10 Dec 2017 16:25:43 +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
Return directly after a failed kcalloc()
drivers/tty/moxa.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
--
2.15.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] tty: moxa: Delete an error message for a failed memory allocation in moxa_init_board()
2017-12-10 15:30 [PATCH 0/2] tty-MOXA: Adjustments for moxa_init_board() SF Markus Elfring
@ 2017-12-10 15:31 ` SF Markus Elfring
2017-12-10 15:32 ` [PATCH 2/2] tty: moxa: Return directly after a failed kcalloc() " SF Markus Elfring
1 sibling, 0 replies; 3+ messages in thread
From: SF Markus Elfring @ 2017-12-10 15:31 UTC (permalink / raw)
To: kernel-janitors, Greg Kroah-Hartman, Jiri Slaby; +Cc: LKML
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 10 Dec 2017 16:03:21 +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 <elfring@users.sourceforge.net>
---
drivers/tty/moxa.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
index 65a70f3c7cde..a74caf05cf57 100644
--- a/drivers/tty/moxa.c
+++ b/drivers/tty/moxa.c
@@ -836,7 +836,6 @@ static int moxa_init_board(struct moxa_board_conf *brd, struct device *dev)
brd->ports = kcalloc(MAX_PORTS_PER_BOARD, sizeof(*brd->ports),
GFP_KERNEL);
if (brd->ports == NULL) {
- printk(KERN_ERR "cannot allocate memory for ports\n");
ret = -ENOMEM;
goto err;
}
--
2.15.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] tty: moxa: Return directly after a failed kcalloc() in moxa_init_board()
2017-12-10 15:30 [PATCH 0/2] tty-MOXA: Adjustments for moxa_init_board() SF Markus Elfring
2017-12-10 15:31 ` [PATCH 1/2] tty: moxa: Delete an error message for a failed memory allocation in moxa_init_board() SF Markus Elfring
@ 2017-12-10 15:32 ` SF Markus Elfring
1 sibling, 0 replies; 3+ messages in thread
From: SF Markus Elfring @ 2017-12-10 15:32 UTC (permalink / raw)
To: kernel-janitors, Greg Kroah-Hartman, Jiri Slaby; +Cc: LKML
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 10 Dec 2017 16:15:41 +0100
* Return directly after a call of the function "kcalloc" failed
at the beginning.
* Delete the jump label "err" which became unnecessary with
this refactoring.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/tty/moxa.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
index a74caf05cf57..571c8456056c 100644
--- a/drivers/tty/moxa.c
+++ b/drivers/tty/moxa.c
@@ -835,10 +835,8 @@ static int moxa_init_board(struct moxa_board_conf *brd, struct device *dev)
brd->ports = kcalloc(MAX_PORTS_PER_BOARD, sizeof(*brd->ports),
GFP_KERNEL);
- if (brd->ports == NULL) {
- ret = -ENOMEM;
- goto err;
- }
+ if (!brd->ports)
+ return -ENOMEM;
for (i = 0, p = brd->ports; i < MAX_PORTS_PER_BOARD; i++, p++) {
tty_port_init(&p->port);
@@ -892,7 +890,6 @@ static int moxa_init_board(struct moxa_board_conf *brd, struct device *dev)
for (i = 0; i < MAX_PORTS_PER_BOARD; i++)
tty_port_destroy(&brd->ports[i].port);
kfree(brd->ports);
-err:
return ret;
}
--
2.15.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-12-10 15:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-10 15:30 [PATCH 0/2] tty-MOXA: Adjustments for moxa_init_board() SF Markus Elfring
2017-12-10 15:31 ` [PATCH 1/2] tty: moxa: Delete an error message for a failed memory allocation in moxa_init_board() SF Markus Elfring
2017-12-10 15:32 ` [PATCH 2/2] tty: moxa: Return directly after a failed kcalloc() " SF Markus Elfring
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).