Make sure gbuf->transfer_buffer gets reset to NULL when the buffer
is freed. We can leverage that to do a little extra error checking.
We'll also use a null transfer buffer in the next patch to indicate
an unused gbuf.
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
u32 cport_reserve = gbuf->dest_cport_id == CPORT_ID_BAD ? 0 : 1;
u8 *buffer;
+ if (gbuf->transfer_buffer)
+ return -EALREADY;
+
if (size > ES1_GBUF_MSG_SIZE) {
pr_err("guf was asked to be bigger than %ld!\n",
ES1_GBUF_MSG_SIZE);
if (gbuf->dest_cport_id != CPORT_ID_BAD)
transfer_buffer--; /* Back up to cport id */
kfree(transfer_buffer);
+ gbuf->transfer_buffer = NULL;
}
#define ES1_TIMEOUT 500 /* 500 ms for the SVC to do something */
struct urb *urb;
transfer_buffer = gbuf->transfer_buffer;
+ if (!transfer_buffer)
+ return -EINVAL;
buffer = &transfer_buffer[-1]; /* yes, we mean -1 */
/* Find a free urb */