summaryrefslogtreecommitdiffstats
path: root/pcidev.c
diff options
context:
space:
mode:
authorStefan Tauner <stefan.tauner@alumni.tuwien.ac.at>2011-07-12 22:35:21 +0000
committerStefan Tauner <stefan.tauner@alumni.tuwien.ac.at>2011-07-12 22:35:21 +0000
commit269de3533ac58de85bf874afcbc862d73e1944c7 (patch)
treeee762ee7695c977df7c4174fb263308a26b543cf /pcidev.c
parentff56267ec0ffefa071f26c22553b9bea216d19f7 (diff)
downloadflashrom-269de3533ac58de85bf874afcbc862d73e1944c7.tar.gz
flashrom-269de3533ac58de85bf874afcbc862d73e1944c7.tar.bz2
flashrom-269de3533ac58de85bf874afcbc862d73e1944c7.zip
Fix unchecked malloc calls and casts of malloc return values
In the long term the exit calls should be replaced by returns. until then this is the correct way to handle failures. the casts are not needed (in C) and we don't cast malloc return values anywhere else. Corresponding to flashrom svn r1370. Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at> Acked-by: Uwe Hermann <uwe@hermann-uwe.de>
Diffstat (limited to 'pcidev.c')
-rw-r--r--pcidev.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/pcidev.c b/pcidev.c
index 1f9a5cc8d..d4ad8bcd5 100644
--- a/pcidev.c
+++ b/pcidev.c
@@ -295,6 +295,10 @@ int undo_pci_write(void *p)
{ \
struct undo_pci_write_data *undo_pci_write_data; \
undo_pci_write_data = malloc(sizeof(struct undo_pci_write_data)); \
+ if (!undo_pci_write_data) { \
+ msg_gerr("Out of memory!\n"); \
+ exit(1); \
+ } \
undo_pci_write_data->dev = *a; \
undo_pci_write_data->reg = b; \
undo_pci_write_data->type = pci_write_type_##c; \