Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp2340191pxb; Sun, 30 Jan 2022 12:48:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJxjnFGkUjm8c0juO9jla/v1GcrtqtR83yToWsqiHc3yszm6w/SC2jIX2Z9MwOUWuR7rNvdy X-Received: by 2002:a05:6402:1e92:: with SMTP id f18mr17897045edf.128.1643575703494; Sun, 30 Jan 2022 12:48:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643575703; cv=none; d=google.com; s=arc-20160816; b=SzvkK/J5+4NRQDD+6209LFD901gaH6BHJx/mpJ4F5z+Qbu8/RuM/97I6LkzvVH6ydR kiuJ57lJ8M5IUPdI/Gc9aEsAKEhbYE+cjBgvf48zzjO80vJgm7/f2g3F9F+LkVOXqcpE EVqUAl1qPIj/sKWnWFMPlQDrAVOc4DyDKYIyxQclZyephrHecL7mgmW2qNhioKIMCsu0 9yK9g9HkHX7U5mwonKwP10hBbLxyqKbmwxNxonzwES6Q25U0Wf/Mft7rgeLSTAsF/gLf jw0rushsAn7B89yURpUgBg02GJSjZE8xM+xX8/HWE95eNg0HBfvxGkXAIU6CUxLO3O4V x+bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=AP1h4mmbYl/TcSR22YZ3H/TBAUMfkHF801G8StLbLHc=; b=Dl2low5qeYYzPaGjRseOq8bs4vEkeM8E4kVB6efmmG0faipOAWCXiiSjBILdW022Ak w+I6b8TDPjGlg8++C7M+XVHPSM+LVupdg7J5xc9EUPOzM/XqYP1c+g9NhpM8Eo8t3niL MrY/DpKBsIIXIv4CyU/Mm/kgHW79GRB+cyPxj/8kY84n5IA9b37xsv7s96hqyVbgdAN1 UT58VjkXI97yyaezpDy7Z4sQ6rUshMdpiw8AmVCeCVNjHWSJLP0Qo2NWFPSlVoMsBxlY f1SF/An0qcm9Fzl5+2XN562aU5fCi8zbq4vSYM7EKTZPUNbCYljwr4b7TTv+SlGpo15D qkgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="C/xJnGSB"; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dr8si6161007ejc.823.2022.01.30.12.47.59; Sun, 30 Jan 2022 12:48:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="C/xJnGSB"; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347549AbiA1Jb5 (ORCPT + 72 others); Fri, 28 Jan 2022 04:31:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238330AbiA1Jb4 (ORCPT ); Fri, 28 Jan 2022 04:31:56 -0500 Received: from mail-qt1-x834.google.com (mail-qt1-x834.google.com [IPv6:2607:f8b0:4864:20::834]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 694A8C061714; Fri, 28 Jan 2022 01:31:56 -0800 (PST) Received: by mail-qt1-x834.google.com with SMTP id e16so4675420qtq.6; Fri, 28 Jan 2022 01:31:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=AP1h4mmbYl/TcSR22YZ3H/TBAUMfkHF801G8StLbLHc=; b=C/xJnGSBeUPtZEo3oZ7dkTKSxGAVE5QdjPJ3cOF0XllUEzsU28PfeApgvtYq9Bwk0y 0p8UpZ8PN563gqWIR08/rK0ubUfX3qWVsyr7YsdIhCMIbeO6uE9d8ro+FMFJVqOfERHn 7+In7yrYxu7CqzHkNNa8hH36wDFJwsGMS45APF1qdGgobEBpbexqIEEB7yhu6kz3veyo d+IaIc9nZJ95GkzFnO0gJl3hikix0scxHJXPJZT2Fyl8dZXLQBrh/YX8bKS5evoCXNYV YrB3/Qx7sTOMg8eXpFnANVP4OlKMmnxaKBZWMNEacJc4tw6USdZG2YJeitcDRzVrhJZS CeYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AP1h4mmbYl/TcSR22YZ3H/TBAUMfkHF801G8StLbLHc=; b=OUY13tsl/bqc5Liqm+VlB6aPISjN4/lD/ZHST0kFNmCYc9bia/FIhqjEa0L1+O4Ekt OAjPvPBTJOevrA00zZJCgkuaSQUS9Z1Z1hBUwL8YfSCe4uHUrPwU/C2sNWmDxFdileya hTkCrxKWy6QsRbwszi59zsOqu7qpWXuPF98yeO5DMKyU20KsTzHUkc4giC8+nswZtWxD 0dqVfDgCIpGB4RPASmV5ASuXlhI56NfCGkbux7A6eyw7G6YX9zLQ1GTqqHWOTAb9xDat cj09Y+AJN9gGdLwlwZ3ieZG7w1B2OtRcqNt/4tKJdx5HK0nySeUK0DBoQqmFo4HZy93U lVPg== X-Gm-Message-State: AOAM532VMYKcR4wcHtj9RFNGeP2TjHPoMPozR1mbCYi62wmY37GXXilN v3rPFBiqmWmNEDF2d+ylNyY= X-Received: by 2002:a05:622a:13cf:: with SMTP id p15mr5524945qtk.16.1643362315588; Fri, 28 Jan 2022 01:31:55 -0800 (PST) Received: from localhost.localdomain ([193.203.214.57]) by smtp.gmail.com with ESMTPSA id y18sm2724302qtj.56.2022.01.28.01.31.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jan 2022 01:31:55 -0800 (PST) From: cgel.zte@gmail.com X-Google-Original-From: chi.minghao@zte.com.cn To: kvalo@kernel.org Cc: cgel.zte@gmail.com, chi.minghao@zte.com.cn, davem@davemloft.net, johannes.berg@intel.com, kuba@kernel.org, linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org, luciano.coelho@intel.com, netdev@vger.kernel.org, trix@redhat.com, zealci@zte.com.cn Subject: [PATCH v2] iwlwifi: dvm: use struct_size over open coded arithmetic Date: Fri, 28 Jan 2022 09:31:47 +0000 Message-Id: <20220128093147.1213351-1-chi.minghao@zte.com.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <87o83wi67x.fsf@kernel.org> References: <87o83wi67x.fsf@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Minghao Chi (CGEL ZTE) Replace zero-length array with flexible-array member and make use of the struct_size() helper in kmalloc(). For example: struct iwl_wipan_noa_data { ... u8 data[]; } Make use of the struct_size() helper instead of an open-coded version in order to avoid any potential type mistakes. Reported-by: Zeal Robot Signed-off-by: Minghao Chi (CGEL ZTE) --- drivers/net/wireless/intel/iwlwifi/dvm/rx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/intel/iwlwifi/dvm/rx.c b/drivers/net/wireless/intel/iwlwifi/dvm/rx.c index db0c41bbeb0e..d0d842b25b86 100644 --- a/drivers/net/wireless/intel/iwlwifi/dvm/rx.c +++ b/drivers/net/wireless/intel/iwlwifi/dvm/rx.c @@ -915,7 +915,7 @@ static void iwlagn_rx_noa_notification(struct iwl_priv *priv, len += 1 + 2; copylen += 1 + 2; - new_data = kmalloc(sizeof(*new_data) + len, GFP_ATOMIC); + new_data = kmalloc(struct_size(*new_data, data, len), GFP_ATOMIC); if (new_data) { new_data->length = len; new_data->data[0] = WLAN_EID_VENDOR_SPECIFIC; -- 2.25.1