From d154f8bda2e379a8a0e1c3712a9af6a9d97b7b97 Mon Sep 17 00:00:00 2001 From: Jacob Erlbeck Date: Thu, 9 Apr 2015 14:22:21 +0200 Subject: msgb: Check the return value of msgb_alloc (Coverity) In some places, the return value of msgb_alloc/msgb_alloc_headroom is not checked before it is dereferenced. This commit adds NULL checks to return with -ENOMEM from the calling functions if the alloc function has failed. Fixes: Coverity CID 1249692, 1293376 Sponsored-by: On-Waves ehf --- src/sim/reader.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/sim') diff --git a/src/sim/reader.c b/src/sim/reader.c index 160f1758..e7169b5a 100644 --- a/src/sim/reader.c +++ b/src/sim/reader.c @@ -58,6 +58,9 @@ static int transceive_apdu_t0(struct osim_card_hdl *st, struct msgb *amsg) uint16_t sw; int rc, num_resp = 0; + if (!tmsg) + return -ENOMEM; + /* create TPDU header from APDU header */ tpduh = (struct osim_apdu_cmd_hdr *) msgb_put(tmsg, sizeof(*tpduh)); memcpy(tpduh, msgb_apdu_h(amsg), sizeof(*tpduh)); -- cgit v1.2.3