From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: [PATCH 1/4] tools/libxl: Avoid deliberate NULL pointer dereference Date: Mon, 25 Nov 2013 11:12:50 +0000 Message-ID: <1385377973-21401-2-git-send-email-andrew.cooper3@citrix.com> References: <1385377973-21401-1-git-send-email-andrew.cooper3@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1385377973-21401-1-git-send-email-andrew.cooper3@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Xen-devel Cc: Andrew Cooper , Ian Jackson , Ian Campbell List-Id: xen-devel@lists.xenproject.org Coverity ID: 1055290 Calling LIBXL__LOG_ERRNO(ctx,) with a ctx pointer we have just failed to allocate is going to end badly. Opencode a suitable use of xtl_log() instead. Signed-off-by: Andrew Cooper CC: Ian Campbell CC: Ian Jackson --- tools/libxl/libxl.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index 9b93262..6263d14 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -31,7 +31,9 @@ int libxl_ctx_alloc(libxl_ctx **pctx, int version, ctx = malloc(sizeof(*ctx)); if (!ctx) { - LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "Failed to allocate context\n"); + xtl_log(lg, XTL_ERROR, errno, "libxl", + "%s:%d:%s: Failed to allocate context\n", + __FILE__, __LINE__, __func__); rc = ERROR_NOMEM; goto out; } -- 1.7.10.4