* Some (new-) network stack fixes
@ 2010-06-14 7:43 Sascha Hauer
2010-06-14 7:43 ` [PATCH 1/3] tftp: do not forget to close the file in error case Sascha Hauer
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Sascha Hauer @ 2010-06-14 7:43 UTC (permalink / raw)
To: barebox
These patches fix some bugs introduced with the new network stack. I'll
squash them into the original patches.
Sascha
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/3] tftp: do not forget to close the file in error case
2010-06-14 7:43 Some (new-) network stack fixes Sascha Hauer
@ 2010-06-14 7:43 ` Sascha Hauer
2010-06-14 7:43 ` [PATCH 2/3] parameter: set p->value to NULL to avoid freeing it again Sascha Hauer
2010-06-14 7:43 ` [PATCH 3/3] dhcp: do not call net_unregister if net_udp_new failed Sascha Hauer
2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2010-06-14 7:43 UTC (permalink / raw)
To: barebox
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
net/tftp.c | 48 ++++++++++++++++++++++--------------------------
1 files changed, 22 insertions(+), 26 deletions(-)
diff --git a/net/tftp.c b/net/tftp.c
index b0bc7c5..38d16bc 100644
--- a/net/tftp.c
+++ b/net/tftp.c
@@ -206,31 +206,11 @@ static void tftp_handler(char *packet, unsigned len)
}
}
-static int tftp_start(char *filename)
-{
- char ip1[16];
-
- tftp_filename = filename;
-
- printf("TFTP from server %s; Filename: '%s'\nLoading: ",
- ip_to_string(net_get_serverip(), ip1),
- tftp_filename);
-
- tftp_timer_start = get_time_ns();
- tftp_state = STATE_RRQ;
- tftp_block = 0;
-
- tftp_con = net_udp_new(net_get_serverip(), TFTP_PORT, tftp_handler);
- if (IS_ERR(tftp_con))
- return PTR_ERR(tftp_con);
-
- return tftp_send();
-}
-
static int do_tftpb(struct command *cmdtp, int argc, char *argv[])
{
char *localfile;
char *remotefile;
+ char ip1[16];
if (argc < 2)
return COMMAND_ERROR_USAGE;
@@ -248,9 +228,25 @@ static int do_tftpb(struct command *cmdtp, int argc, char *argv[])
return 1;
}
- tftp_err = tftp_start(remotefile);
+ tftp_con = net_udp_new(net_get_serverip(), TFTP_PORT, tftp_handler);
+ if (IS_ERR(tftp_con)) {
+ tftp_err = PTR_ERR(tftp_con);
+ goto out_close;
+ }
+
+ tftp_filename = remotefile;
+
+ printf("TFTP from server %s; Filename: '%s'\nLoading: ",
+ ip_to_string(net_get_serverip(), ip1),
+ tftp_filename);
+
+ tftp_timer_start = get_time_ns();
+ tftp_state = STATE_RRQ;
+ tftp_block = 0;
+
+ tftp_err = tftp_send();
if (tftp_err)
- goto out;
+ goto out_unreg;
while (tftp_state != STATE_DONE) {
if (ctrlc()) {
@@ -264,11 +260,11 @@ static int do_tftpb(struct command *cmdtp, int argc, char *argv[])
tftp_send();
}
}
-
+out_unreg:
net_unregister(tftp_con);
-
+out_close:
close(net_store_fd);
-out:
+
if (tftp_err) {
printf("\ntftp failed: %s\n", strerror(-tftp_err));
unlink(localfile);
--
1.7.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/3] parameter: set p->value to NULL to avoid freeing it again
2010-06-14 7:43 Some (new-) network stack fixes Sascha Hauer
2010-06-14 7:43 ` [PATCH 1/3] tftp: do not forget to close the file in error case Sascha Hauer
@ 2010-06-14 7:43 ` Sascha Hauer
2010-06-14 7:43 ` [PATCH 3/3] dhcp: do not call net_unregister if net_udp_new failed Sascha Hauer
2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2010-06-14 7:43 UTC (permalink / raw)
To: barebox
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
lib/parameter.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/lib/parameter.c b/lib/parameter.c
index a3d178f..0aa4193 100644
--- a/lib/parameter.c
+++ b/lib/parameter.c
@@ -129,8 +129,10 @@ int dev_param_set_generic(struct device_d *dev, struct param_d *p,
{
if (p->value)
free(p->value);
- if (!val)
+ if (!val) {
+ p->value = NULL;
return 0;
+ }
p->value = strdup(val);
return 0;
}
--
1.7.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 3/3] dhcp: do not call net_unregister if net_udp_new failed
2010-06-14 7:43 Some (new-) network stack fixes Sascha Hauer
2010-06-14 7:43 ` [PATCH 1/3] tftp: do not forget to close the file in error case Sascha Hauer
2010-06-14 7:43 ` [PATCH 2/3] parameter: set p->value to NULL to avoid freeing it again Sascha Hauer
@ 2010-06-14 7:43 ` Sascha Hauer
2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2010-06-14 7:43 UTC (permalink / raw)
To: barebox
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
net/dhcp.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/net/dhcp.c b/net/dhcp.c
index 54c5179..0771964 100644
--- a/net/dhcp.c
+++ b/net/dhcp.c
@@ -447,13 +447,13 @@ static int do_dhcp(struct command *cmdtp, int argc, char *argv[])
ret = net_udp_bind(dhcp_con, PORT_BOOTPC);
if (ret)
- goto out;
+ goto out1;
net_set_ip(0);
ret = bootp_request(); /* Basically same as BOOTP */
if (ret)
- goto out;
+ goto out1;
while (dhcp_state != BOUND) {
if (ctrlc())
@@ -464,13 +464,13 @@ static int do_dhcp(struct command *cmdtp, int argc, char *argv[])
printf("T ");
ret = bootp_request();
if (ret)
- goto out;
+ goto out1;
}
}
-out:
+out1:
net_unregister(dhcp_con);
-
+out:
if (ret)
printf("dhcp failed: %s\n", strerror(-ret));
--
1.7.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-06-14 7:43 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-14 7:43 Some (new-) network stack fixes Sascha Hauer
2010-06-14 7:43 ` [PATCH 1/3] tftp: do not forget to close the file in error case Sascha Hauer
2010-06-14 7:43 ` [PATCH 2/3] parameter: set p->value to NULL to avoid freeing it again Sascha Hauer
2010-06-14 7:43 ` [PATCH 3/3] dhcp: do not call net_unregister if net_udp_new failed Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox