[PATCH 2/2] tty: moxa: Return directly after a failed kcalloc() in moxa_init_board()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
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@xxxxxxxxxxxxxxxxxxxxx>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux