Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp6954736ybf; Fri, 6 Mar 2020 07:39:08 -0800 (PST) X-Google-Smtp-Source: ADFU+vt+FKaJimryut78e89+GalvQ/CNAKJkX5uud3XJB9/PDmF2+Gbw3K3TuntzDr0VTt/ovsBH X-Received: by 2002:aca:4c91:: with SMTP id z139mr3021563oia.150.1583509148785; Fri, 06 Mar 2020 07:39:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583509148; cv=none; d=google.com; s=arc-20160816; b=CFfsV6/gD6moQHe78d/aTiFq9Ni6pe4JynLv8NMRTQNfxRY8EZaD05Wq5nT9lqZH+q OuaU1Cn64YaiiPBuW+yzryPpnZTErC2MHcFX+A7cLPp51YEcw1PxdTUiUYD5Ytsu5OfT 2CZnzoT+xch+6sx8udr8PO77YOh8RjUFe/8/u+P69OL8pC0X7/XMfnM11BQvmZXVFYKa cN80fw70OOW2Ld7Zj/tkLZLaaAUvP8A8kCkmtnKfHrdtYKflecmpCOuX/YAHg0S9F+gT spmntu86sKk3Bd28jv7y45dhax/INjQaLoDo2/Ahxmf9extMd9GMROz6565xVNWgAmry Kqgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=j6sXql4oSXT6Q/ws5TYxgRAPlqnRvsWRJL+OU5ImErY=; b=l5JisNgNs07YjOEFDV1sIOjmveyPi2MufqnTXnnr0dxkE7IBsyN3KW+yZW2N6fQHPL rxhc49kianK/GJ0Ak5MvOZKYyhSPmcNUKSgftWP0RHPUk4okwfAeA98a2tpsn0ypl8Pu iD3dwwFVNUzj7Qx65fIH1fIgmoDehXxGqjSMS7LL2hlzcDJye8UgPOtHWpTWGeFDT7ru 976i/Lp++gQznmcqu+9ueBmUkaMjCBaRNptmtzEkNsUA0YQJu19DwM1u0T7wZq2OhMsf dxWnFjldqulTQ2r/Ro9tbxgkXwcO5ayFuFSydStK+jK9XZNzGdNdT5Z5JuI8jiVoetq/ m+Fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lca.pw header.s=google header.b=YAqiAObC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 22si1561534oij.227.2020.03.06.07.38.54; Fri, 06 Mar 2020 07:39:08 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@lca.pw header.s=google header.b=YAqiAObC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727194AbgCFPhY (ORCPT + 99 others); Fri, 6 Mar 2020 10:37:24 -0500 Received: from mail-qk1-f194.google.com ([209.85.222.194]:41264 "EHLO mail-qk1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726382AbgCFPhY (ORCPT ); Fri, 6 Mar 2020 10:37:24 -0500 Received: by mail-qk1-f194.google.com with SMTP id b5so2651805qkh.8 for ; Fri, 06 Mar 2020 07:37:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lca.pw; s=google; h=from:to:cc:subject:date:message-id; bh=j6sXql4oSXT6Q/ws5TYxgRAPlqnRvsWRJL+OU5ImErY=; b=YAqiAObC9L8ErnG6/sYX0Zx1A4YfyyMtalpuashj3Fr1rvx0oV1OTzOsf1WWd5r0Ca i+rVg+EPA+7B8n4SzAQBM96nGiG7YpOWr3ldTbt4yPhe+3suFzHaAuvNWtiPfdWgFQbB pkC+mQsm5hMdAydfzA3Znr9vsufyjEQL10k4hXn7OL81+feViHmmYOG/rgMttm5whuRf 7HUsfjEYrCq2jLdGGJkmywIhcwW8IJHjIsLL+MlYXHPgaJQHc4Oc2VasPVdIWN4zzAEm gBTHTQQcFMLOG2dgiAClPkxa6C2ODhB5T3Q1grlW+yo2942vwg11v77ivtsKG77Cy7F7 4fDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=j6sXql4oSXT6Q/ws5TYxgRAPlqnRvsWRJL+OU5ImErY=; b=sO1ad0N0H2+0VgVTnzPSD6qPDZa+7KyeKlicAxzLBGkvoqbGr+nDgwPOPdBesCPp+Y 2BIVFDinFr7ek/af/w5m4v8XLWe0uImelyM80DZx/k9OZPIjy7VX+tpnPA9XNL80vsWJ RLzCaB3OY3j7FO0V7t4hKoO8SZEnRjVmK7o5mlQbHiTOm/GM6XtLYT+KY0Jwx9lkod1X QSioHL4p0zkA/3B74QDyoa52349YEffSvWsc0pBJWsNlSMD/CcByq3HMdPQIVERBp7HC ifZTB5uzLE/cqQTrysOL1U8ByxDei8DBi4DfkPRb7p6crStsaBglyZuZKYL2vaH5T9FK ZMrg== X-Gm-Message-State: ANhLgQ1tctBiOq9qdqd4tGSyzlIj9sixuvhBLP1r3ED/s54kcxwFPFel RM1dJksRrUUsFb0dJgmHC7uWLA== X-Received: by 2002:a37:a80c:: with SMTP id r12mr3278127qke.241.1583509043047; Fri, 06 Mar 2020 07:37:23 -0800 (PST) Received: from qcai.nay.com (nat-pool-bos-t.redhat.com. [66.187.233.206]) by smtp.gmail.com with ESMTPSA id t3sm16038837qkt.114.2020.03.06.07.37.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Mar 2020 07:37:22 -0800 (PST) From: Qian Cai To: akpm@linux-foundation.org Cc: aryabinin@virtuozzo.com, glider@google.com, dvyukov@google.com, walter-zh.wu@mediatek.com, kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Qian Cai Subject: [PATCH -next] kasan/tags: fix -Wdeclaration-after-statement warn Date: Fri, 6 Mar 2020 10:37:10 -0500 Message-Id: <1583509030-27939-1-git-send-email-cai@lca.pw> X-Mailer: git-send-email 1.8.3.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The linux-next commit "kasan: detect negative size in memory operation function" introduced a compilation warning, mm/kasan/tags_report.c:51:27: warning: ISO C90 forbids mixing declarations and code [-Wdeclaration-after-statement] struct kasan_alloc_meta *alloc_meta; Fix it by moving a code around a bit where there is no strict dependency. Signed-off-by: Qian Cai --- mm/kasan/tags_report.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/mm/kasan/tags_report.c b/mm/kasan/tags_report.c index 1d412760551a..bee43717d6f0 100644 --- a/mm/kasan/tags_report.c +++ b/mm/kasan/tags_report.c @@ -36,17 +36,6 @@ const char *get_bug_type(struct kasan_access_info *info) { - /* - * If access_size is a negative number, then it has reason to be - * defined as out-of-bounds bug type. - * - * Casting negative numbers to size_t would indeed turn up as - * a large size_t and its value will be larger than ULONG_MAX/2, - * so that this can qualify as out-of-bounds. - */ - if (info->access_addr + info->access_size < info->access_addr) - return "out-of-bounds"; - #ifdef CONFIG_KASAN_SW_TAGS_IDENTIFY struct kasan_alloc_meta *alloc_meta; struct kmem_cache *cache; @@ -71,6 +60,17 @@ const char *get_bug_type(struct kasan_access_info *info) } #endif + /* + * If access_size is a negative number, then it has reason to be + * defined as out-of-bounds bug type. + * + * Casting negative numbers to size_t would indeed turn up as + * a large size_t and its value will be larger than ULONG_MAX/2, + * so that this can qualify as out-of-bounds. + */ + if (info->access_addr + info->access_size < info->access_addr) + return "out-of-bounds"; + return "invalid-access"; } -- 1.8.3.1