From patchwork Fri Oct 14 08:49:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Elo, Matias \(Nokia - FI/Espoo\)" X-Patchwork-Id: 77649 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp197132qge; Fri, 14 Oct 2016 01:52:05 -0700 (PDT) X-Received: by 10.237.44.193 with SMTP id g59mr11220549qtd.144.1476435125801; Fri, 14 Oct 2016 01:52:05 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id j26si9059280qtj.98.2016.10.14.01.52.05; Fri, 14 Oct 2016 01:52:05 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE dis=NONE) header.from=nokia.com Received: by lists.linaro.org (Postfix, from userid 109) id 68F7460A34; Fri, 14 Oct 2016 08:52:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAD_ENC_HEADER,BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id A08A360D04; Fri, 14 Oct 2016 08:50:34 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id A22C961B6A; Fri, 14 Oct 2016 08:50:27 +0000 (UTC) Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on0131.outbound.protection.outlook.com [104.47.1.131]) by lists.linaro.org (Postfix) with ESMTPS id 28C9961B8E for ; Fri, 14 Oct 2016 08:49:34 +0000 (UTC) Received: from HE1PR0701CA0058.eurprd07.prod.outlook.com (10.168.191.26) by HE1PR0701MB2265.eurprd07.prod.outlook.com (10.168.36.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.669.5; Fri, 14 Oct 2016 08:49:32 +0000 Received: from AM1FFO11OLC005.protection.gbl (2a01:111:f400:7e00::162) by HE1PR0701CA0058.outlook.office365.com (2603:10a6:3:9e::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.669.5 via Frontend Transport; Fri, 14 Oct 2016 08:49:31 +0000 Received-SPF: Pass (protection.outlook.com: domain of nokia.com designates 131.228.2.241 as permitted sender) receiver=protection.outlook.com; client-ip=131.228.2.241; helo=fihe3nok0735.emea.nsn-net.net; Received: from fihe3nok0735.emea.nsn-net.net (131.228.2.241) by AM1FFO11OLC005.mail.protection.outlook.com (10.174.64.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.669.7 via Frontend Transport; Fri, 14 Oct 2016 08:49:30 +0000 Received: from fihe3nok0735.emea.nsn-net.net (localhost [127.0.0.1]) by fihe3nok0735.emea.nsn-net.net (8.14.9/8.14.5) with ESMTP id u9E8nCWu005818 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 14 Oct 2016 11:49:12 +0300 Received: from 10.144.19.15 ([10.144.104.92]) by fihe3nok0735.emea.nsn-net.net (8.14.9/8.14.5) with ESMTP id u9E8nCVm005806 (version=TLSv1/SSLv3 cipher=AES128-SHA256 bits=128 verify=NOT) for ; Fri, 14 Oct 2016 11:49:12 +0300 X-HPESVCS-Source-Ip: 10.144.104.92 From: Matias Elo To: Date: Fri, 14 Oct 2016 11:49:09 +0300 Message-ID: <1476434952-8282-3-git-send-email-matias.elo@nokia.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1476434952-8282-1-git-send-email-matias.elo@nokia.com> References: <1476434952-8282-1-git-send-email-matias.elo@nokia.com> X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:131.228.2.241; IPV:NLI; CTRY:FI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(7916002)(2980300002)(438002)(189002)(199003)(68736007)(7846002)(2906002)(586003)(5660300001)(76176999)(8676002)(626004)(229853001)(450100001)(2351001)(2950100002)(5003940100001)(11100500001)(42882006)(48376002)(19580395003)(50226002)(19580405001)(81166006)(81156014)(106466001)(305945005)(6916009)(110136003)(50466002)(107886002)(8936002)(6666003)(356003)(77096005)(36756003)(92566002)(97736004)(50986999)(189998001)(33646002)(47776003)(87936001)(217873001); DIR:OUT; SFP:1102; SCL:1; SRVR:HE1PR0701MB2265; H:fihe3nok0735.emea.nsn-net.net; FPR:; SPF:Pass; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; AM1FFO11OLC005; 1:8rBc4cnPzh3+U5rfoDq53z7zkfXvCxpwSqfIMG2U6ft+lJ/pW03nDFjhk6nBrASnbfrywOBPFGB9BV/UiOzSUiGi+ibChjzBfd7Mnh/z/qGVr0gf3hSLrAVggPC9vxcdVUPQcx7PdQxa07DE1T/W+mOaCx/i7U3pTV3mfNLa19qecNEhW01lXb5hSHBcF7s7+trYlfJxcURSYvsZsX1xudZJY9exJkV+wpxWEbivGXmFmTZkG+E3DHzDWfqBOweXPSV2TEVpzmAYT2YZmWLHA08ye/d/t+loW8eIdApXQIl7kXeY7mpQescGn0Z3l22saY5PQz3pFzl/mS+Nfg5d2sls6OTiKXsRbSsecbOMdnaRVB8VMER+uKtzufGl8V1UHnza3a59czvwDJtZw1CXx66eA0Fd73RNv5CFv25s5wqsIFs7K0OFbYWYfOw0J6QeS6rM/k8MnOmdmbKpzRGePgm74/DFP7Zxm6wOIFl5o4roVOoFKV+5DoyEXO2lF4yw MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 891de74a-f044-46fb-fa0c-08d3f40f03c5 X-Microsoft-Exchange-Diagnostics: 1; HE1PR0701MB2265; 2:Uc/Mu97Ja4TFlf+O2lt384GDAZtb9DmAcyCl9w50Ybp1COSOAG8hWFHSGeDcpZx5ONTp/Vce9qVj2bfXNuv7sN74DsjmtTj8Yzhf92EcG7VA4+TXaN9eUiBD6KoqLEN0vhn425uVjeSkW33llCQ9qjmIaLtj3Z5mGbFBP10varvj48xUARiSKxke4NlMaPvkNnuLA7k2cWJxjAX7TaIhOA==; 3:c3kDgJEvGFLWVeZT9WZOmukbNsQiBSt2hZLmpFuaN68huF1nnVbSFmYqkVoctpLAHmHXC/TaucMzG+P0n3ru0s33jwKDjLDoIupfd7PI+zVhqdslytoWxtGU2eZYLMuTgtDvDTOm5XvbZfSQBzUaMb2Py7hn7eV4gnHfjbhiZ1vV+B1dSw/PdVEzqqPFPVs9+IUlOyUP0uz9vUaFjRFFix3+IeNvDwgj9/heBzY7r8CFRVhF4IftBHWDJ1t0v+jrRnMdXDws/CcR5/WJ8g7STdsDX2MLJ0DDE99U0KY6udA= X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(8251501002); SRVR:HE1PR0701MB2265; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0701MB2265; 25:D8sTeT+ND77OG4Y6FWGN/VSfoHK6LeYj3eKj/uH4dmJ+JwD9Q0Qbmj8z/lRgv0ylK80JWCbAhcWBZMhVIiyGUV3tiWREj3YOzJp80Dt9KA5MNLeHjbUJ8tzqMN5ToVnkzKh5F5r8kG9UuimeHRTDn1vFV2kOfj8dozUaNp9JwheukD1orZFM56acemFjwNuK7m67Q55xcSCv0fjCS3X55suguzhwjLlDSCYfqFPmE487fhzyHyseG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hWX2bC4u7EqT7Hv2hJcPUqtmNwqy7GIsExKXNXgwKq+4bKWmkIW1PlzQX7rGms110OJev5EeYc+L7qYKpvhXRVRcoKTU70QL2Xm25t4C9+Vpw5FJckLd01//RxQQ+OQxGugl/7NGL/JQH/wJwPcOOY6PxY3Vfvr8xUaTDhS//fJZ/QWKcuZaPhWzSKk1E95A8ak6z8ZQ4NvMZ3AhDKbpMkR4Vq+6wu9/SfJetfQJ2bp/iMEj3xf7FbSHvAiEtzRM3AK7ezwqboqdmU9BmVBFrQKxvKxAxScIVl5WrL/lKaeNUg3mUNUzy+/gbFZ8WjlDxL/K/BL6nnaSh+ioVjwSzlhRmu77TG2CiBkK/4J9H/kGFV/RmGg+WsY1c2QDe3xpNXunzWmQkad57g= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(82608151540597); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(13018025)(5005006)(13016025)(8121501046)(10201501046)(3002001)(6055026); SRVR:HE1PR0701MB2265; BCL:0; PCL:0; RULEID:; SRVR:HE1PR0701MB2265; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0701MB2265; 4:PuykeIoW1jWuFokAWSykIUAlwaLeGisFk56PBYOpdSCjJGBsvAUP1fTS9ndyxO5CyEhPzabx8WwCp5R36qJaT+u+ugI4xW+VgKgcPnSaEw4ytYVVFj+hETQmPye81h08jU8z7Escu7sgEO2Bke96kF4zu3we3CebBZmVBIeY+Y7iGvzb64jjrKVjcKQoyp+dnbAUgPkxoFb7ifwpcYi+0MoAgTs2yp7kewSLWCfF1t9bLE86t/mYftOB9oLlD5qKaRi7/ee9OagrVnPqmeNgptgVlX+gqFxo4haSPC7HMUyJcZnNoyXIhi/ZpKEtPKIQI/0iGZA3vINPuh5sGbthUlpzKPbQKYfCYIlCPJ9Vtko1n4wDjAJg5hMEvV2OuwaMI26/+C/SsYvHdBhn09l1yYPDrv9jKo/I8V6d6lKbruac9SaRbCGpqH89PER8FETdxHuTrODBwHPj9510CFI/LZiBUW3mw9SwW870wAdkoC5I6EhV9IQ5985FJsvSSr0q X-Forefront-PRVS: 0095BCF226 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HE1PR0701MB2265; 23:yQouknC31PmFwi1ekuX5k86M8E3tvgwimAz3TFc?= =?us-ascii?Q?0JSnhK5lDPwiLEDLw0XLVhgRJ6NuY9EOTGNkyU36t5G/P4FaUtGXclfF5ob2?= =?us-ascii?Q?ygpxliKhW6d4ul50wTOu//u6Y8odbVJ7/TIMwUL1n+/ltIYbJx/zrjawpoMM?= =?us-ascii?Q?O+LLOpQlbHqm7IPDJUS5cl5vyfp0o0wVfgLbDzmyzY+v1oOQGVC/52qkGnkK?= =?us-ascii?Q?nfRBlBa39+rK1uQIKNrU64KP2umdOKCV96sDj2Y5S4YIUtiZYe4hfBtyOb3z?= =?us-ascii?Q?qpqEJa79tX3jDlU1Zefk2OJgmkUSf9sK+OWJlFueFk6G/IwA3q0cXWnkMLkC?= =?us-ascii?Q?//gNXj7b+j5GL20504+LZ4isgFOTIcR6JEOwL1vzVBOc21qWIjeHkcqOfiV+?= =?us-ascii?Q?yVImvk5j/X23hux7RbLm/EAc0ngTv0QGd4I5CuR6Zj4B4nURP6MRHJwHkwcX?= =?us-ascii?Q?QasRYml9ypEtUG84zZvFHvWIy+CNjKjtsheKx85q7jJICkIfQFVlJRxsXPE0?= =?us-ascii?Q?Fvl49EdYIrO8o1uxwU9tbogw/YURKjRjDKvdcixhewyRNeVXDQvmmeU1aLrz?= =?us-ascii?Q?iNpLSX4NQmNBMQLOE0/E+N5XnZQYTngtqE2B20Orc2d8cNyfS3jA16ewpaLI?= =?us-ascii?Q?CWZhkUbz95/CiVDlym16Y5APoxvmKjb0e3AWcjiWAb77gLk7OHT995c1kgt/?= =?us-ascii?Q?MYJY1M9cbiKHshZmlqdxvUSjb9QNyRQYAUpirfsfEBqkCM/WBDYSjksbnlk7?= =?us-ascii?Q?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DHuJ3xCaV2Q8zwTSQwYRMw55DtvYk7ZGJqvpmewBlH/1a+ewM5XqL+f+oc= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; HE1PR0701MB2265; 7:I0PaSpLwcYR/k6EmYefmxFWaV7cwcqSXbZhSoerZhmnEpnEgWlyaa85kMUnhPXDdQeN7TQllWM5Lx95LuAjcEsRiXcC5KqIt05LhuiE8WhpoeBrkwGcZSUDHXP7iI/VK1lYHD4iRtUZVnzGd4XsjlQr25KV80to5jrBzg9zdW3OPg4zaO1P4c5OTREjujBWG3QPhJJ3nMVuWtAzNFBUwD4qdK6qPzT+o4TolLFB1ikTbOLcWAOFhl3ZB8Y50vDcka4JNvmNAE481ab2RrUsohceEconKsSvrIBL8bj1uFbrZPSzVAXbsU56HgQucCsQbDxFT75YerLwMKeZ5Wcva4Ton7iMS+4Fuw8fwjrNoqdo= X-OriginatorOrg: nokia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Oct 2016 08:49:30.9372 (UTC) X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0; Ip=[131.228.2.241]; Helo=[fihe3nok0735.emea.nsn-net.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0701MB2265 X-Topics: patch Subject: [lng-odp] [API-NEXT PATCH 2/5] linux-gen: schedule: fix creating event group with no name X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" Previously trying to create an event group with no name (=NULL) caused a segfault. Fix this and test it in the validation suite. Signed-off-by: Matias Elo --- platform/linux-generic/odp_schedule.c | 26 +++++++++++++++------- platform/linux-generic/odp_schedule_sp.c | 11 +++++++-- .../validation/api/scheduler/scheduler.c | 9 +++++++- 3 files changed, 35 insertions(+), 11 deletions(-) -- 2.7.4 diff --git a/platform/linux-generic/odp_schedule.c b/platform/linux-generic/odp_schedule.c index 78982d9..e24eec3 100644 --- a/platform/linux-generic/odp_schedule.c +++ b/platform/linux-generic/odp_schedule.c @@ -181,6 +181,7 @@ typedef struct { struct { char name[ODP_SCHED_GROUP_NAME_LEN]; odp_thrmask_t mask; + int allocated; } sched_grp[NUM_SCHED_GRPS]; struct { @@ -869,11 +870,19 @@ static odp_schedule_group_t schedule_group_create(const char *name, odp_spinlock_lock(&sched->grp_lock); for (i = SCHED_GROUP_NAMED; i < NUM_SCHED_GRPS; i++) { - if (sched->sched_grp[i].name[0] == 0) { - strncpy(sched->sched_grp[i].name, name, - ODP_SCHED_GROUP_NAME_LEN - 1); + if (!sched->sched_grp[i].allocated) { + char *grp_name = sched->sched_grp[i].name; + + if (name == NULL) { + grp_name[0] = 0; + } else { + strncpy(grp_name, name, + ODP_SCHED_GROUP_NAME_LEN - 1); + grp_name[ODP_SCHED_GROUP_NAME_LEN - 1] = 0; + } odp_thrmask_copy(&sched->sched_grp[i].mask, mask); group = (odp_schedule_group_t)i; + sched->sched_grp[i].allocated = 1; break; } } @@ -889,10 +898,11 @@ static int schedule_group_destroy(odp_schedule_group_t group) odp_spinlock_lock(&sched->grp_lock); if (group < NUM_SCHED_GRPS && group >= SCHED_GROUP_NAMED && - sched->sched_grp[group].name[0] != 0) { + sched->sched_grp[group].allocated) { odp_thrmask_zero(&sched->sched_grp[group].mask); memset(sched->sched_grp[group].name, 0, ODP_SCHED_GROUP_NAME_LEN); + sched->sched_grp[group].allocated = 0; ret = 0; } else { ret = -1; @@ -928,7 +938,7 @@ static int schedule_group_join(odp_schedule_group_t group, odp_spinlock_lock(&sched->grp_lock); if (group < NUM_SCHED_GRPS && group >= SCHED_GROUP_NAMED && - sched->sched_grp[group].name[0] != 0) { + sched->sched_grp[group].allocated) { odp_thrmask_or(&sched->sched_grp[group].mask, &sched->sched_grp[group].mask, mask); @@ -949,7 +959,7 @@ static int schedule_group_leave(odp_schedule_group_t group, odp_spinlock_lock(&sched->grp_lock); if (group < NUM_SCHED_GRPS && group >= SCHED_GROUP_NAMED && - sched->sched_grp[group].name[0] != 0) { + sched->sched_grp[group].allocated) { odp_thrmask_t leavemask; odp_thrmask_xor(&leavemask, mask, &sched->mask_all); @@ -973,7 +983,7 @@ static int schedule_group_thrmask(odp_schedule_group_t group, odp_spinlock_lock(&sched->grp_lock); if (group < NUM_SCHED_GRPS && group >= SCHED_GROUP_NAMED && - sched->sched_grp[group].name[0] != 0) { + sched->sched_grp[group].allocated) { *thrmask = sched->sched_grp[group].mask; ret = 0; } else { @@ -992,7 +1002,7 @@ static int schedule_group_info(odp_schedule_group_t group, odp_spinlock_lock(&sched->grp_lock); if (group < NUM_SCHED_GRPS && group >= SCHED_GROUP_NAMED && - sched->sched_grp[group].name[0] != 0) { + sched->sched_grp[group].allocated) { info->name = sched->sched_grp[group].name; info->thrmask = sched->sched_grp[group].mask; ret = 0; diff --git a/platform/linux-generic/odp_schedule_sp.c b/platform/linux-generic/odp_schedule_sp.c index 2e28aa4..b7b1de4 100644 --- a/platform/linux-generic/odp_schedule_sp.c +++ b/platform/linux-generic/odp_schedule_sp.c @@ -501,8 +501,15 @@ static odp_schedule_group_t schedule_group_create(const char *name, for (i = NUM_STATIC_GROUP; i < NUM_GROUP; i++) { if (!sched_group->s.group[i].allocated) { - strncpy(sched_group->s.group[i].name, name, - ODP_SCHED_GROUP_NAME_LEN); + char *grp_name = sched_group->s.group[i].name; + + if (name == NULL) { + grp_name[0] = 0; + } else { + strncpy(grp_name, name, + ODP_SCHED_GROUP_NAME_LEN - 1); + grp_name[ODP_SCHED_GROUP_NAME_LEN - 1] = 0; + } odp_thrmask_copy(&sched_group->s.group[i].mask, thrmask); sched_group->s.group[i].allocated = 1; diff --git a/test/common_plat/validation/api/scheduler/scheduler.c b/test/common_plat/validation/api/scheduler/scheduler.c index 919cfb6..dd3f6cd 100644 --- a/test/common_plat/validation/api/scheduler/scheduler.c +++ b/test/common_plat/validation/api/scheduler/scheduler.c @@ -273,7 +273,7 @@ void scheduler_test_groups(void) ODP_SCHED_SYNC_ORDERED}; int thr_id = odp_thread_id(); odp_thrmask_t zeromask, mymask, testmask; - odp_schedule_group_t mygrp1, mygrp2, lookup; + odp_schedule_group_t mygrp1, mygrp2, null_grp, lookup; odp_schedule_group_info_t info; odp_thrmask_zero(&zeromask); @@ -327,6 +327,10 @@ void scheduler_test_groups(void) CU_ASSERT(rc == 0); CU_ASSERT(!odp_thrmask_isset(&testmask, thr_id)); + /* Create group with no name */ + null_grp = odp_schedule_group_create(NULL, &zeromask); + CU_ASSERT(null_grp != ODP_SCHED_GROUP_INVALID); + /* We shouldn't be able to find our second group before creating it */ lookup = odp_schedule_group_lookup("Test Group 2"); CU_ASSERT(lookup == ODP_SCHED_GROUP_INVALID); @@ -338,6 +342,9 @@ void scheduler_test_groups(void) lookup = odp_schedule_group_lookup("Test Group 2"); CU_ASSERT(lookup == mygrp2); + /* Destroy group with no name */ + CU_ASSERT_FATAL(odp_schedule_group_destroy(null_grp) == 0); + /* Verify we're not part of it */ rc = odp_schedule_group_thrmask(mygrp2, &testmask); CU_ASSERT(rc == 0);