summaryrefslogtreecommitdiffstats
path: root/src/net
diff options
context:
space:
mode:
authorMichael Brown2017-03-21 14:20:45 +0100
committerMichael Brown2017-03-21 14:20:59 +0100
commitf17cf0ecd0363523dde781338fb1f3b5f5a7c6f7 (patch)
treeb4d701e27f5fd41c9ce5fac77bbf1d9b094e0b35 /src/net
parent[eoib] Avoid passing a NULL I/O buffer to netdev_tx_complete_err() (diff)
downloadipxe-f17cf0ecd0363523dde781338fb1f3b5f5a7c6f7.tar.gz
ipxe-f17cf0ecd0363523dde781338fb1f3b5f5a7c6f7.tar.xz
ipxe-f17cf0ecd0363523dde781338fb1f3b5f5a7c6f7.zip
[http] Add missing check for memory allocation failure
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/net')
-rw-r--r--src/net/tcp/httpconn.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/net/tcp/httpconn.c b/src/net/tcp/httpconn.c
index a2c01a41..2cfca9c9 100644
--- a/src/net/tcp/httpconn.c
+++ b/src/net/tcp/httpconn.c
@@ -277,6 +277,10 @@ int http_connect ( struct interface *xfer, struct uri *uri ) {
/* Allocate and initialise structure */
conn = zalloc ( sizeof ( *conn ) );
+ if ( ! conn ) {
+ rc = -ENOMEM;
+ goto err_alloc;
+ }
ref_init ( &conn->refcnt, http_conn_free );
conn->uri = uri_get ( uri );
conn->scheme = scheme;
@@ -310,5 +314,6 @@ int http_connect ( struct interface *xfer, struct uri *uri ) {
conn->scheme->name, conn->uri->host, port, strerror ( rc ) );
http_conn_close ( conn, rc );
ref_put ( &conn->refcnt );
+ err_alloc:
return rc;
}