From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 54DD4A04B5; Wed, 28 Oct 2020 22:19:12 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 9D5D35A8C; Wed, 28 Oct 2020 22:19:09 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id 430945A51; Wed, 28 Oct 2020 22:19:07 +0100 (CET) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 09SL1glZ031218; Wed, 28 Oct 2020 14:19:04 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=date : from : to : cc : subject : message-id : references : content-type : in-reply-to : mime-version; s=pfpt0220; bh=km+pEBpF5Y+pBEDcbVgPBkT5mr2e7v1wGPvW0LOassE=; b=gTDvLME1T1eDicmPhXYw3ftKFHxEzQdoa/DTiGk8lSckINsZbFqhhj6xcCzQ5/n7Xrb8 c8l81DkvhuqG2nTkVYn1dceL13GHAbCO4MXSj3vMjJ69VGilvtVM0UCyhSHc+fDfNusv X3szP9sH/ikOFQ5wZwNN0kYTXgVzIg/Ugelt1yBIe5HFfXQX1eO21c6Uz3vAjva9Jw7+ FhyX+N3InXJumeH88kxYYTx4AiwRRK/Ze3tdifjs3+DOyrmX8X3v7ihxV/sDuuqFx5Nc 7TLOYagbd31TQKJiEy3EFgAbiL9T5BK+hq70awrPIaduYY9nRQ6rHSinD9bigIJoKo7R Sw== Received: from sc-exch02.marvell.com ([199.233.58.182]) by mx0b-0016f401.pphosted.com with ESMTP id 34cksmhb9g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 28 Oct 2020 14:19:04 -0700 Received: from SC-EXCH02.marvell.com (10.93.176.82) by SC-EXCH02.marvell.com (10.93.176.82) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 28 Oct 2020 14:19:02 -0700 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (104.47.70.103) by SC-EXCH02.marvell.com (10.93.176.82) with Microsoft SMTP Server (TLS) id 15.0.1497.2 via Frontend Transport; Wed, 28 Oct 2020 14:19:02 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Zy6FRlB1n/IfY0zCC3W8Oq8Zqo2bYATupwXmEvsl0RvK1rAPyjR+NMUT+LJWjhINxjhb/ty3N0SFhiC/HeePyO74KPekjwuBb4islxhh5cTMjjHHdi/HedHBoVSue0QQMfN6IJPDIx9zIs1Zvy+jrUAgcOSwHwCxzv0so5fepaWwOeJlTmBhyUs3AElOltTbaecbSyVb6MccjMnnvL48Fvrn/70x5B7Tt6AvnuLQy3MexdAP0jUf7zMDpXrvKxFqR/88DImtFKWE1eA/99fw21/OUzgnK6ybEp6NB8LbuE3g4izmVxFRzmzsImcninCXw9kH6ThhWl/G+YPzZOhwMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=km+pEBpF5Y+pBEDcbVgPBkT5mr2e7v1wGPvW0LOassE=; b=EXrCeJs7EgF1ZZwZv21cKZ8arrWxDVYP6lcTx5whJQyUo2o8+aWqNZMZ856gKOMjc97tdM3S3n+MfnDKakixo1Vv36OwL7i619vMWb4h1T0jYRLW3I7FJt4qDp+mhBNTNGClLGAoyLQx3O0QG/8rVIhtqaMITfootY3oL77af1s2uTIHV1PcX75j5FN0INhUAjsoGeN+zS6j3OJYuHL0V2/jsBTZBSTv8rZv3Fa8fuuTKt2nBIxhML84avDMeVPU7Bj1xbvuEZN3BX2jo+c7lkUTog8NGNc6yfl5u8uP3A0/cg0yXvpiBfVVm8G8CEDF8oPkNInI8F0rsV4CQO0Mfg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=marvell.com; dmarc=pass action=none header.from=marvell.com; dkim=pass header.d=marvell.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.onmicrosoft.com; s=selector1-marvell-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=km+pEBpF5Y+pBEDcbVgPBkT5mr2e7v1wGPvW0LOassE=; b=nm9dg3J/hrsEEOB0myyiLhHaJzLPppwAO8b4HDhmDeaxMaWDgrNyupif8V5dd9JgvRhtJRLOQ1ABgeudEy034udeAS1MTu7DgzOGU8GItUu2pA0ZaSRG/HB+v6S29pInpa7ZYn0nK4kTmJ93W3gcmo6KrhA08OzQMeeiKAnb+go= Authentication-Results: huawei.com; dkim=none (message not signed) header.d=none;huawei.com; dmarc=none action=none header.from=marvell.com; Received: from CO6PR18MB3842.namprd18.prod.outlook.com (2603:10b6:5:341::16) by CO6PR18MB3810.namprd18.prod.outlook.com (2603:10b6:5:347::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.27; Wed, 28 Oct 2020 21:19:00 +0000 Received: from CO6PR18MB3842.namprd18.prod.outlook.com ([fe80::b960:6770:a1:2a19]) by CO6PR18MB3842.namprd18.prod.outlook.com ([fe80::b960:6770:a1:2a19%7]) with mapi id 15.20.3499.027; Wed, 28 Oct 2020 21:19:00 +0000 Date: Thu, 29 Oct 2020 02:48:46 +0530 From: Harman Kalra To: wangyunjian CC: , , , , , , Message-ID: <20201028211845.GB137989@outlook.office365.com> References: <1600511670-27576-1-git-send-email-wangyunjian@huawei.com> <1602751350-2808-1-git-send-email-wangyunjian@huawei.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1602751350-2808-1-git-send-email-wangyunjian@huawei.com> User-Agent: Mutt/1.10.0 (2018-05-17) X-Originating-IP: [1.6.215.26] X-ClientProxiedBy: BM1PR01CA0156.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:68::26) To CO6PR18MB3842.namprd18.prod.outlook.com (2603:10b6:5:341::16) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from outlook.office365.com (1.6.215.26) by BM1PR01CA0156.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:68::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Wed, 28 Oct 2020 21:18:57 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c8dfb23c-ba30-4756-bbf9-08d87b871665 X-MS-TrafficTypeDiagnostic: CO6PR18MB3810: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Zkin3ucRA0nemzKbUr3OQNNVxYB14MlB5jSPqyQ3ZjTqxRIYo27m3WSWkmw8t9Aaygh8DHD8pwc321X64eVkbyviBM/fXR+TAXoopxpSq+L87/OMSyMJgofSBakPQQeswlCSrF+amA7WqiDj3JcqR3ZW/IFUwHdiq/AV7m8bcYk4oNPh+jIdpNYzoh61I4h4Q5MWXzjxa9C8iaVspHZwipt3Q7L28r+V5ElNq/4L91qDdgTITyUdu17bmRpgnQxjmqRWuI+ChvfJ4adgXgs14G7rruzKz7rq5PF64WSaJ/+uDNjp5oKDrRRsEIbDciZXvmLuSmqULJ/7gBp6DiQCbYbroAIvQyx5msfE1xoTJlpy3rSp2LhCLDEHgg0x/W+U3Lw2uBHr4XOBUYjrd1klLg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CO6PR18MB3842.namprd18.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(396003)(346002)(136003)(39860400002)(366004)(7696005)(8936002)(8676002)(52116002)(6506007)(4326008)(1076003)(66946007)(66476007)(66556008)(33656002)(5660300002)(86362001)(83380400001)(16526019)(186003)(316002)(9686003)(6916009)(55016002)(2906002)(6666004)(1006002)(956004)(478600001)(26005)(36456003)(42976004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: cg6eUw7o5b+JmM1L9KLbYGKzjsoHgMDsCKwK7KyWQ8DDI3FhnCrDMTg7NG8wrzs7Y1//Wa0KDdkz/Mxv8owPjBvhKkMK2n75ZmgAs60kPEbo9tUXlIdbKEDRURiNR03xwlIUVm7v8lpYJ27QOvZIBDaUiPJikT0WVEbWAvKEprGXexfOu0DXfve/dpgobbwfJaOdOfcWvZsSkXl/JpP0vUAFgZoRJsHgC8KhFGbPwwanO+LDCGx8hsJ4GgCXrfY3IO1waOXKXvUggyaIWUbI7l6/QbD8XA59v1yu5JNq+p1bm7fFGMuxGlrGz4PfGdUs6O4S478RbkRVh7oU07iPeTAi/G5J91hbf1lrKpAGKLyTn/fJaA3tXI+AjuUDY+pStmijcrBbGjncqj591mNvx+qWH99fZNQETlIj0b2imGVlp9swI/5CttqxJ+aPZidrjmS9Qd83l8NKYgtpHZJzfnLQB2qSVRIlchbpkzgndH/Yals+1VRxXaYnb1tLeWOJyy9nFJyOV42EX8okh9Jh7xrpbfMnJ236CdoFr8jFLT6kk0/dU8sq405DbHBw+47sAFu9BuAeis4WGmVbZNV/5e9l+AfyOMe5aSlsq9Fw0vHuf7lv16fsblvNS2CW7j8Lx++WuHrN8jkVlNteExYvlg== X-MS-Exchange-CrossTenant-Network-Message-Id: c8dfb23c-ba30-4756-bbf9-08d87b871665 X-MS-Exchange-CrossTenant-AuthSource: CO6PR18MB3842.namprd18.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Oct 2020 21:19:00.0597 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 70e1fb47-1155-421d-87fc-2e58f638b6e0 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 70HIMsUb1qXcCUkCsqczT9tLiClboyC4kn8HrJzDdK8IKHJWf0/b61qPQn3IZ+4OYwKnirlMtCTpDGFvamBHhA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR18MB3810 X-OriginatorOrg: marvell.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.312, 18.0.737 definitions=2020-10-28_09:2020-10-28, 2020-10-28 signatures=0 Subject: Re: [dpdk-dev] [EXT] [PATCH v2] eal: fix dereference after null check X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Thu, Oct 15, 2020 at 04:42:30PM +0800, wangyunjian wrote: > External Email > > ---------------------------------------------------------------------- > From: Yunjian Wang > > This patch fixes (dereference after null check) coverity issue. > For this reason, we should add null check at the beginning of the > function and return error directly if the 'intr_handle' is null. > > Coverity issue: 357695, 357751 > Fixes: 05c4105738d8 ("trace: add interrupt tracepoints") > Cc: stable@dpdk.org > > Signed-off-by: Yunjian Wang Thanks for fixing this. Reviewed-by: Harman Kalra > --- > v2: > fix code styles suggested by Ferruh Yigit > --- > lib/librte_eal/freebsd/eal_interrupts.c | 16 ++++++++++------ > lib/librte_eal/linux/eal_interrupts.c | 16 ++++++++++------ > 2 files changed, 20 insertions(+), 12 deletions(-) > > diff --git a/lib/librte_eal/freebsd/eal_interrupts.c b/lib/librte_eal/freebsd/eal_interrupts.c > index 6d53d33c8..211fd4f8d 100644 > --- a/lib/librte_eal/freebsd/eal_interrupts.c > +++ b/lib/librte_eal/freebsd/eal_interrupts.c > @@ -350,13 +350,15 @@ rte_intr_enable(const struct rte_intr_handle *intr_handle) > { > int rc = 0; > > - if (intr_handle && intr_handle->type == RTE_INTR_HANDLE_VDEV) { > + if (intr_handle == NULL) > + return -1; > + > + if (intr_handle->type == RTE_INTR_HANDLE_VDEV) { > rc = 0; > goto out; > } > > - if (!intr_handle || intr_handle->fd < 0 || > - intr_handle->uio_cfg_fd < 0) { > + if (intr_handle->fd < 0 || intr_handle->uio_cfg_fd < 0) { > rc = -1; > goto out; > } > @@ -389,13 +391,15 @@ rte_intr_disable(const struct rte_intr_handle *intr_handle) > { > int rc = 0; > > - if (intr_handle && intr_handle->type == RTE_INTR_HANDLE_VDEV) { > + if (intr_handle == NULL) > + return -1; > + > + if (intr_handle->type == RTE_INTR_HANDLE_VDEV) { > rc = 0; > goto out; > } > > - if (!intr_handle || intr_handle->fd < 0 || > - intr_handle->uio_cfg_fd < 0) { > + if (intr_handle->fd < 0 || intr_handle->uio_cfg_fd < 0) { > rc = -1; > goto out; > } > diff --git a/lib/librte_eal/linux/eal_interrupts.c b/lib/librte_eal/linux/eal_interrupts.c > index 13db5c4e8..f1bd0356c 100644 > --- a/lib/librte_eal/linux/eal_interrupts.c > +++ b/lib/librte_eal/linux/eal_interrupts.c > @@ -667,13 +667,15 @@ rte_intr_enable(const struct rte_intr_handle *intr_handle) > { > int rc = 0; > > - if (intr_handle && intr_handle->type == RTE_INTR_HANDLE_VDEV) { > + if (intr_handle == NULL) > + return -1; > + > + if (intr_handle->type == RTE_INTR_HANDLE_VDEV) { > rc = 0; > goto out; > } > > - if (!intr_handle || intr_handle->fd < 0 || > - intr_handle->uio_cfg_fd < 0) { > + if (intr_handle->fd < 0 || intr_handle->uio_cfg_fd < 0) { > rc = -1; > goto out; > } > @@ -794,13 +796,15 @@ rte_intr_disable(const struct rte_intr_handle *intr_handle) > { > int rc = 0; > > - if (intr_handle && intr_handle->type == RTE_INTR_HANDLE_VDEV) { > + if (intr_handle == NULL) > + return -1; > + > + if (intr_handle->type == RTE_INTR_HANDLE_VDEV) { > rc = 0; > goto out; > } > > - if (!intr_handle || intr_handle->fd < 0 || > - intr_handle->uio_cfg_fd < 0) { > + if (intr_handle->fd < 0 || intr_handle->uio_cfg_fd < 0) { > rc = -1; > goto out; > } > -- > 2.23.0 >