Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752131AbdI0R5c (ORCPT ); Wed, 27 Sep 2017 13:57:32 -0400 Received: from mail-by2nam03on0071.outbound.protection.outlook.com ([104.47.42.71]:11776 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751016AbdI0R5a (ORCPT ); Wed, 27 Sep 2017 13:57:30 -0400 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=fail action=none header.from=nxp.com; From: Ioana Radulescu To: CC: , , , , , , , , Subject: [PATCH] staging: fsl-mc/dpio: Fix incorrect comparison Date: Wed, 27 Sep 2017 12:57:28 -0500 Message-ID: <20170927175728.3307-1-ruxandra.radulescu@nxp.com> X-Mailer: git-send-email 2.11.0 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131510086488287979;(91ab9b29-cfa4-454e-5278-08d120cd25b8);() X-Forefront-Antispam-Report: CIP:192.88.168.50;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(336005)(39380400002)(346002)(376002)(39860400002)(2980300002)(1109001)(1110001)(339900001)(199003)(189002)(50466002)(85426001)(2351001)(16586007)(48376002)(106466001)(498600001)(105606002)(316002)(86362001)(8656003)(2906002)(104016004)(1076002)(97736004)(36756003)(7416002)(8936002)(5660300001)(39060400002)(54906003)(305945005)(68736007)(4326008)(53936002)(50226002)(6916009)(50986999)(189998001)(81156014)(8676002)(77096006)(356003)(81166006)(33646002)(5003940100001)(47776003);DIR:OUT;SFP:1101;SCL:1;SRVR:MWHPR03MB2701;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;PTR:InfoDomainNonexistent;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BL2FFO11FD009;1:0vvSErZ8MEs0yfb9YZ6OEXw07ARTkvmqCTYhSAbY6scNV7NXwJ290Cpw/KZng6fiJUTn253Ic0u6Uw04/sYKd/bKZrSv1vcTbharA0C/yD0pMhiBxO3XdvOLEbB79Ip/ MIME-Version: 1.0 Content-Type: text/plain X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cc6de6bd-b40c-400b-eaeb-08d505d137fa X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(2017052603199)(201703131430075)(201703131517081);SRVR:MWHPR03MB2701; X-Microsoft-Exchange-Diagnostics: 1;MWHPR03MB2701;3:EFT7C6n/OAOfAeEhXGX3XNOUWIwaI+RrDfn2FB+um1P6wPz8atRWJo/T0aSgLWJY7eZCo7ie+B6wzex61/R54K8ImDnfX5pWSuUKRMqT+Qkh4jVYg4U2ziToEf4TI7pw+vBlZSFiVXyp4hXokkDl5URV8g9ONycgZfPY6x5DCFnRb+NJgQ/O7GcBtAm3UgR7D4lbRR/iU25zu2AW+3nnsPpnzZN3vcm8IQD6S43o/LChByZUXPdH4o5+0S4VeEHQJDLXyB8l2O+O2puzko5sOOvymGdCBnKQDC325ko4zoWo5w2RBByAEAH1bfAnGKRuGc/EFSNQiTj/ZIklABoJqdZsOb4YwIXW7Y+y8RTB+Tg=;25:RidPZPJSZ2os/y8xoVKLR830h/e+PzfkcdFhebL2SMWgXa/lTo58Ej80eORFZd5vZ3n2BuZhI60W22xPHtWOrOKHDKkUFn9dfDXVQyPnJ+LhWQq8mjMKabDEWkVDn0W7NUyqIKnBEgpzDnt0KU5ETDoVIeo4QwrSgOvpHaZgWnRm0DkKcWfikt1mxuyOiEgXEuZ+CY5SfbkStPayOlXaC4OXA3TpPoXjjGt3IbFdXfGmcKw16cU3nCJdOyy9zo9/mAWw5givohB6WEFiHuFNbcABpP8tlSRWQKTyjCWN+oRfMDu/H6OqvdM15AIV8CWh/plrt52O32JeLvaiKEXXkA== X-MS-TrafficTypeDiagnostic: MWHPR03MB2701: X-Microsoft-Exchange-Diagnostics: 1;MWHPR03MB2701;31:zf7TbO7i5O2KvtjkzOtjyq7ykqGMrrmSYzGA1pPdf5n+EEo2FmRrePyjfZM0r9c3JerKLD1YHdWfAnFcDDtTg4yY1kT6BLTbIhr4dIoW9+B+hONMyULCGI9Iboq88YuYkRqvDljIlC+cLqlHb16opqMKhyU/1TBVYldMgoihFCwMeb6UQwsnTuIyhDZgfI0Bso15qWeVQETzB22qNPZ4XneK+j9Mf9xQk20AR2RvkVg=;4:y/Q9Q9In9aIxCBYjqzYzVB86OuLZIJZPagHNAQjyptFNkg5GWYBEusEArFrCQ30xreCrFAUbxVDPw5YdI+z5J0V0K0tdU8K4UA1iCHmGbNeo/ZSmIgApvz9Zi5WXAUvaKMm4G8HuXgdZa3CHV7oKlPKv49MtdvXANe1MIgS1b/zmOlHLCeEuLIu5413dsjyDmb7hl6UaDYhmXFuP7CgMn2FFpbKc0K+NMeppIXIvV1oUZ1OduGycrkWX9UMEMEikd+OwyVhnNdIj0qGyLDcfJgdQXg8QLvhu/UcIUagqTEQ= X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6095135)(2401047)(8121501046)(5005006)(3002001)(10201501046)(100000703101)(100105400095)(93006095)(93001095)(6055026)(6096035)(201703131430075)(201703131448075)(201703131433075)(201703161259150)(201703151042153)(20161123559100)(20161123563025)(20161123561025)(20161123556025)(20161123565025)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:MWHPR03MB2701;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(400006)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:MWHPR03MB2701; X-Forefront-PRVS: 04433051BF X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;MWHPR03MB2701;23:IGNxGLSnfihsfXmqtZRowQKY1qcBjb0O+WN+E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ps1JFai/zdM6wtkSM516oW1locF0RfZTohW1mzrJHNPA98b4WT5WKBdeLmC7IN3x19CSxMjPBhAaM/tuKwrvCprXYO6WuCTgzvwowGa004ZnaK+q7GwDnAUsyvO4oMzxzgdM= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Sep 2017 17:57:28.6727 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e;Ip=[192.88.168.50];Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR03MB2701 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1324 Lines: 38 For some dpio functions, a negative cpu id parameter value is valid and means "any". But when trying to validate this param value against an upper limit, in this case num_possible_cpus(), we risk obtaining the wrong result due to an implicit cast to unsigned. Avoid an incorrect check result when cpu id is negative, by explicitly stating the comparison is between signed values. Signed-off-by: Ioana Radulescu --- drivers/staging/fsl-mc/bus/dpio/dpio-service.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/fsl-mc/bus/dpio/dpio-service.c b/drivers/staging/fsl-mc/bus/dpio/dpio-service.c index f809682..26922fc 100644 --- a/drivers/staging/fsl-mc/bus/dpio/dpio-service.c +++ b/drivers/staging/fsl-mc/bus/dpio/dpio-service.c @@ -76,7 +76,7 @@ static inline struct dpaa2_io *service_select_by_cpu(struct dpaa2_io *d, if (d) return d; - if (unlikely(cpu >= num_possible_cpus())) + if (unlikely(cpu >= (int)num_possible_cpus())) return NULL; /* @@ -121,7 +121,7 @@ struct dpaa2_io *dpaa2_io_create(const struct dpaa2_io_desc *desc) return NULL; /* check if CPU is out of range (-1 means any cpu) */ - if (desc->cpu >= num_possible_cpus()) { + if (desc->cpu >= (int)num_possible_cpus()) { kfree(obj); return NULL; } -- 2.7.4