From patchwork Sun Apr 17 01:26:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: han.lu@intel.com X-Patchwork-Id: 8862381 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 158EEBF29F for ; Sun, 17 Apr 2016 01:26:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3D08420221 for ; Sun, 17 Apr 2016 01:26:51 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id C6B30201C0 for ; Sun, 17 Apr 2016 01:26:49 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 4A545261691; Sun, 17 Apr 2016 03:26:47 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id AB026261691; Sun, 17 Apr 2016 03:26:39 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 6E3742616B9; Sun, 17 Apr 2016 03:26:37 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by alsa0.perex.cz (Postfix) with ESMTP id 4BB002604BE for ; Sun, 17 Apr 2016 03:26:30 +0200 (CEST) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga101.jf.intel.com with ESMTP; 16 Apr 2016 18:26:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,494,1455004800"; d="scan'208";a="786413832" Received: from hanlu-optiplex-9020.sh.intel.com ([10.239.13.11]) by orsmga003.jf.intel.com with ESMTP; 16 Apr 2016 18:26:26 -0700 From: han.lu@intel.com To: tiwai@suse.de, liam.r.girdwood@linux.intel.com, alsa-devel@alsa-project.org Date: Sun, 17 Apr 2016 09:26:45 +0800 Message-Id: <1460856405-28390-1-git-send-email-han.lu@intel.com> X-Mailer: git-send-email 2.5.0 Cc: "Lu, Han" Subject: [alsa-devel] [PATCH 1/1] alsabat: add terminate status check for capture thread X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP From: "Lu, Han" In loopback test, alsabat use pthread_join(pthread_t thread, **retval) to wait for the capture thread to terminate. If the capture thread was canceled, PTHREAD_CANCELED is placed in *retval, and the access to the **retval will fail. Add status check to prevent illegal access to the **retval. Signed-off-by: Lu, Han diff --git a/bat/bat.c b/bat/bat.c index e824065..1afdcb4 100644 --- a/bat/bat.c +++ b/bat/bat.c @@ -192,6 +192,12 @@ static void test_loopback(struct bat *bat) exit(EXIT_FAILURE); } + /* check if capture thread is canceled or not */ + if (thread_result_capture == PTHREAD_CANCELED) { + fprintf(bat->log, _("Capture canceled.\n")); + return; + } + /* check capture status */ if (*thread_result_capture != 0) { fprintf(bat->err, _("Exit capture thread fail: %d\n"),