From: Tedd Ho-Jeong An <hj.tedd.an@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: tedd.an@intel.com
Subject: [PATCH 4/6] emulator: Fix the unchecked return value
Date: Fri, 20 Nov 2020 12:07:10 -0800 [thread overview]
Message-ID: <20201120200712.491219-4-tedd.an@intel.com> (raw)
In-Reply-To: <20201120200712.491219-1-tedd.an@intel.com>
This patch fixes the unchecked return value.
---
emulator/phy.c | 10 ++++++++--
emulator/server.c | 6 +++++-
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/emulator/phy.c b/emulator/phy.c
index 4517ad107..2ae6ad3a2 100644
--- a/emulator/phy.c
+++ b/emulator/phy.c
@@ -115,7 +115,10 @@ static int create_rx_socket(void)
if (fd < 0)
return -1;
- setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt));
+ if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) < 0) {
+ close(fd);
+ return -1;
+ }
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
@@ -138,7 +141,10 @@ static int create_tx_socket(void)
if (fd < 0)
return -1;
- setsockopt(fd, SOL_SOCKET, SO_BROADCAST, &opt, sizeof(opt));
+ if (setsockopt(fd, SOL_SOCKET, SO_BROADCAST, &opt, sizeof(opt)) < 0) {
+ close(fd);
+ return -1;
+ }
return fd;
}
diff --git a/emulator/server.c b/emulator/server.c
index 3b07a7156..ceb417a40 100644
--- a/emulator/server.c
+++ b/emulator/server.c
@@ -322,7 +322,11 @@ static int open_tcp(void)
return -1;
}
- setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt));
+ if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) < 0) {
+ perror("Failed to set socket option");
+ close(fd);
+ return -1;
+ }
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
--
2.25.4
next prev parent reply other threads:[~2020-11-20 20:07 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-20 20:07 [PATCH 1/6] monitor: Fix potential memory leak Tedd Ho-Jeong An
2020-11-20 20:07 ` [PATCH 2/6] monitor: Fix the unchecked return value Tedd Ho-Jeong An
2020-11-20 20:07 ` [PATCH 3/6] btio: " Tedd Ho-Jeong An
2020-11-20 20:07 ` Tedd Ho-Jeong An [this message]
2020-11-20 20:07 ` [PATCH 5/6] profile/bnep: " Tedd Ho-Jeong An
2020-11-20 20:07 ` [PATCH 6/6] lib: " Tedd Ho-Jeong An
2020-11-20 20:27 ` [1/6] monitor: Fix potential memory leak bluez.test.bot
2020-11-24 21:22 ` Luiz Augusto von Dentz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201120200712.491219-4-tedd.an@intel.com \
--to=hj.tedd.an@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=tedd.an@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).