All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] acd: check fd return to satisfy static analysis
@ 2021-02-08 19:27 James Prestwood
  2021-02-08 19:27 ` [PATCH 2/3] dhcp: free rtnl address on error James Prestwood
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: James Prestwood @ 2021-02-08 19:27 UTC (permalink / raw)
  To: ell

[-- Attachment #1: Type: text/plain, Size: 814 bytes --]

---
 ell/acd.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/ell/acd.c b/ell/acd.c
index 6381747..d5c5024 100644
--- a/ell/acd.c
+++ b/ell/acd.c
@@ -129,6 +129,9 @@ static int acd_send_packet(struct l_acd *acd, uint32_t source_ip)
 	int n;
 	int fd = l_io_get_fd(acd->io);
 
+	if (fd < 0)
+		return fd;
+
 	memset(&dest, 0, sizeof(dest));
 	memset(&p, 0, sizeof(p));
 
@@ -260,9 +263,13 @@ static bool acd_read_handler(struct l_io *io, void *user_data)
 	int source_conflict;
 	int target_conflict;
 	bool probe;
+	int fd = l_io_get_fd(acd->io);
+
+	if (fd < 0)
+		return true;
 
 	memset(&arp, 0, sizeof(arp));
-	len = read(l_io_get_fd(acd->io), &arp, sizeof(arp));
+	len = read(fd, &arp, sizeof(arp));
 	if (len < 0)
 		return false;
 
-- 
2.26.2

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/3] dhcp: free rtnl address on error
  2021-02-08 19:27 [PATCH 1/3] acd: check fd return to satisfy static analysis James Prestwood
@ 2021-02-08 19:27 ` James Prestwood
  2021-02-08 19:35   ` Denis Kenzior
  2021-02-08 19:27 ` [PATCH 3/3] unit: free cli_addr at end of test James Prestwood
  2021-02-08 19:34 ` [PATCH 1/3] acd: check fd return to satisfy static analysis Denis Kenzior
  2 siblings, 1 reply; 6+ messages in thread
From: James Prestwood @ 2021-02-08 19:27 UTC (permalink / raw)
  To: ell

[-- Attachment #1: Type: text/plain, Size: 514 bytes --]

---
 ell/dhcp.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/ell/dhcp.c b/ell/dhcp.c
index f212e9b..d05ec70 100644
--- a/ell/dhcp.c
+++ b/ell/dhcp.c
@@ -740,8 +740,10 @@ static int dhcp_client_receive_ack(struct l_dhcp_client *client,
 						client, NULL);
 		if (client->rtnl_add_cmdid)
 			client->rtnl_configured_address = a;
-		else
+		else {
 			CLIENT_DEBUG("Configuring address via RTNL failed");
+			l_rtnl_address_free(a);
+		}
 	}
 
 	return r;
-- 
2.26.2

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/3] unit: free cli_addr at end of test
  2021-02-08 19:27 [PATCH 1/3] acd: check fd return to satisfy static analysis James Prestwood
  2021-02-08 19:27 ` [PATCH 2/3] dhcp: free rtnl address on error James Prestwood
@ 2021-02-08 19:27 ` James Prestwood
  2021-02-08 19:36   ` Denis Kenzior
  2021-02-08 19:34 ` [PATCH 1/3] acd: check fd return to satisfy static analysis Denis Kenzior
  2 siblings, 1 reply; 6+ messages in thread
From: James Prestwood @ 2021-02-08 19:27 UTC (permalink / raw)
  To: ell

[-- Attachment #1: Type: text/plain, Size: 455 bytes --]

---
 unit/test-dhcp.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/unit/test-dhcp.c b/unit/test-dhcp.c
index ad06c14..d67b1b5 100644
--- a/unit/test-dhcp.c
+++ b/unit/test-dhcp.c
@@ -1001,6 +1001,7 @@ static void test_expired_ip_reuse(const void *data)
 	assert(lease);
 	cli_addr = l_dhcp_lease_get_address(lease);
 	assert(!strcmp(cli_addr, "192.168.1.2"));
+	l_free(cli_addr);
 }
 
 int main(int argc, char *argv[])
-- 
2.26.2

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/3] acd: check fd return to satisfy static analysis
  2021-02-08 19:27 [PATCH 1/3] acd: check fd return to satisfy static analysis James Prestwood
  2021-02-08 19:27 ` [PATCH 2/3] dhcp: free rtnl address on error James Prestwood
  2021-02-08 19:27 ` [PATCH 3/3] unit: free cli_addr at end of test James Prestwood
@ 2021-02-08 19:34 ` Denis Kenzior
  2 siblings, 0 replies; 6+ messages in thread
From: Denis Kenzior @ 2021-02-08 19:34 UTC (permalink / raw)
  To: ell

[-- Attachment #1: Type: text/plain, Size: 1129 bytes --]

Hi James,

On 2/8/21 1:27 PM, James Prestwood wrote:
> ---
>   ell/acd.c | 9 ++++++++-
>   1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/ell/acd.c b/ell/acd.c
> index 6381747..d5c5024 100644
> --- a/ell/acd.c
> +++ b/ell/acd.c
> @@ -129,6 +129,9 @@ static int acd_send_packet(struct l_acd *acd, uint32_t source_ip)
>   	int n;
>   	int fd = l_io_get_fd(acd->io);
>   
> +	if (fd < 0)
> +		return fd;
> +

Nah, don't bother with these.  If the socket is invalid, the destroy handler 
should be set / notified.

>   	memset(&dest, 0, sizeof(dest));
>   	memset(&p, 0, sizeof(p));
>   
> @@ -260,9 +263,13 @@ static bool acd_read_handler(struct l_io *io, void *user_data)
>   	int source_conflict;
>   	int target_conflict;
>   	bool probe;
> +	int fd = l_io_get_fd(acd->io);
> +
> +	if (fd < 0)
> +		return true;

And it can't be negative in the read handler anyway.

>   
>   	memset(&arp, 0, sizeof(arp));
> -	len = read(l_io_get_fd(acd->io), &arp, sizeof(arp));
> +	len = read(fd, &arp, sizeof(arp));
>   	if (len < 0)
>   		return false;
>   
> 

Regards,
-Denis

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/3] dhcp: free rtnl address on error
  2021-02-08 19:27 ` [PATCH 2/3] dhcp: free rtnl address on error James Prestwood
@ 2021-02-08 19:35   ` Denis Kenzior
  0 siblings, 0 replies; 6+ messages in thread
From: Denis Kenzior @ 2021-02-08 19:35 UTC (permalink / raw)
  To: ell

[-- Attachment #1: Type: text/plain, Size: 184 bytes --]

Hi James,

On 2/8/21 1:27 PM, James Prestwood wrote:
> ---
>   ell/dhcp.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 

Applied, thanks.

Regards,
-Denis

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 3/3] unit: free cli_addr at end of test
  2021-02-08 19:27 ` [PATCH 3/3] unit: free cli_addr at end of test James Prestwood
@ 2021-02-08 19:36   ` Denis Kenzior
  0 siblings, 0 replies; 6+ messages in thread
From: Denis Kenzior @ 2021-02-08 19:36 UTC (permalink / raw)
  To: ell

[-- Attachment #1: Type: text/plain, Size: 239 bytes --]

Hi James,

On 2/8/21 1:27 PM, James Prestwood wrote:
> ---
>   unit/test-dhcp.c | 1 +
>   1 file changed, 1 insertion(+)
> 

I pushed out almost the same patch in commit
a0d6a77dd3b5ccac976fca54836200f350427013

Regards,
-Denis

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-02-08 19:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-08 19:27 [PATCH 1/3] acd: check fd return to satisfy static analysis James Prestwood
2021-02-08 19:27 ` [PATCH 2/3] dhcp: free rtnl address on error James Prestwood
2021-02-08 19:35   ` Denis Kenzior
2021-02-08 19:27 ` [PATCH 3/3] unit: free cli_addr at end of test James Prestwood
2021-02-08 19:36   ` Denis Kenzior
2021-02-08 19:34 ` [PATCH 1/3] acd: check fd return to satisfy static analysis Denis Kenzior

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.