summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Stefan Richter 2010-06-05 14:55:53 +0200
committerGravatar Stefan Richter 2010-09-07 11:18:05 +0200
commit9d47becf251d8601e834e777d6f7f10eb62ec8dc (patch)
treeb4456c1c530787eda26ed71d784efdc4aca9f8c3
parentFix for overlooked device HUP with 'firewire' stack (diff)
Add missing malloc failure checks
Also add errno = ENOMEM because it is said that that some malloc implementations might miss to do so. Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Diffstat (limited to '')
-rw-r--r--src/fw-iso.c4
-rw-r--r--src/fw.c20
2 files changed, 19 insertions, 5 deletions
diff --git a/src/fw-iso.c b/src/fw-iso.c
index 88909dc..5aac9fe 100644
--- a/src/fw-iso.c
+++ b/src/fw-iso.c
@@ -463,8 +463,10 @@ iso_init(fw_handle_t handle, int type,
handle->iso.packet_count = 0;
handle->iso.packets =
malloc(handle->iso.irq_interval * sizeof handle->iso.packets[0]);
- if (handle->iso.packets == NULL)
+ if (handle->iso.packets == NULL) {
+ errno = ENOMEM;
return -1;
+ }
handle->iso.fd = open(handle->iso.filename, O_RDWR);
if (handle->iso.fd < 0) {
diff --git a/src/fw.c b/src/fw.c
index d525ac9..f92c1b6 100644
--- a/src/fw.c
+++ b/src/fw.c
@@ -419,9 +419,13 @@ fw_handle_t fw_new_handle(void)
struct epoll_event ep;
int i;
- memset(&ep, 0, sizeof(ep));
-
handle = malloc(sizeof *handle);
+ if (handle == NULL) {
+ errno = ENOMEM;
+ return NULL;
+ }
+
+ memset(&ep, 0, sizeof(ep));
memset(handle, 0, sizeof(*handle));
handle->tag_handler = default_tag_handler;
@@ -775,6 +779,10 @@ handle_arm_request(raw1394handle_t handle, struct address_closure *ac,
return 0;
rrb = malloc(sizeof *rrb + in_length + response.length);
+ if (rrb == NULL) {
+ errno == ENOMEM;
+ return -1;
+ }
rrb->request_response.request = &rrb->request;
rrb->request_response.response = &rrb->response;
@@ -818,8 +826,10 @@ fw_arm_register(fw_handle_t handle, nodeaddr_t start,
int retval;
allocation = malloc(sizeof *allocation + length);
- if (allocation == NULL)
+ if (allocation == NULL) {
+ errno = ENOMEM;
return -1;
+ }
allocation->closure.callback = handle_arm_request;
allocation->buffer = initial_value;
@@ -1318,8 +1328,10 @@ fw_start_fcp_listen(fw_handle_t handle)
struct address_closure *closure;
closure = malloc(sizeof *closure);
- if (closure == NULL)
+ if (closure == NULL) {
+ errno = ENOMEM;
return -1;
+ }
closure->callback = handle_fcp_request;
class='logmsg'> git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@30 53a565d1-3bb7-0310-b661-cf11e63c67ab 2000-06-11Added explicit AC_PROG_INSTALL call.Gravatar aeb 1-0/+1 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@29 53a565d1-3bb7-0310-b661-cf11e63c67ab 2000-06-09Fix size of error field.Gravatar aeb 1-2/+2 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@28 53a565d1-3bb7-0310-b661-cf11e63c67ab 2000-06-02Modified support for 32/64 bit environments, control struct fields have ↵Gravatar aeb 7-43/+28 fixed size now. git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@27 53a565d1-3bb7-0310-b661-cf11e63c67ab 2000-05-28Added support for environments with 64 bit kernel and 32 bit userland.Gravatar aeb 8-7/+45 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@26 53a565d1-3bb7-0310-b661-cf11e63c67ab 2000-04-27Fixed missing setting of ext code in raw1394_start_lock()Gravatar aeb 1-0/+1 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@25 53a565d1-3bb7-0310-b661-cf11e63c67ab 2000-04-15Fixed lock transaction to actually return response value.Gravatar aeb 3-5/+11 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@24 53a565d1-3bb7-0310-b661-cf11e63c67ab 2000-04-12Add userdata functions as news.Gravatar aeb 1-0/+4 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@23 53a565d1-3bb7-0310-b661-cf11e63c67ab 2000-04-05Add userdata functions.Gravatar aeb 3-0/+18 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@22 53a565d1-3bb7-0310-b661-cf11e63c67ab 2000-03-18Bump version number to 0.6.Gravatar aeb 3-5/+6 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@21 53a565d1-3bb7-0310-b661-cf11e63c67ab 2000-03-18Mention byte order change.Gravatar aeb 1-0/+2 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@20 53a565d1-3bb7-0310-b661-cf11e63c67ab 2000-03-18Mention SourceForge home.Gravatar aeb 1-1/+5 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@19 53a565d1-3bb7-0310-b661-cf11e63c67ab