Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp2453736ybi; Sun, 9 Jun 2019 12:10:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqyo7DPn9X55y1DAEQRNjuonbJiImweMBnvMSZbCO2/a1toSuNyc9thtAwhn7NQKj4L7U9Nc X-Received: by 2002:a17:90a:2ec2:: with SMTP id h2mr17516700pjs.119.1560107445128; Sun, 09 Jun 2019 12:10:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560107445; cv=none; d=google.com; s=arc-20160816; b=qhY5txgtn7fIPizmedmUUe8yKWbjahi+l/dPf8VhWQ7UYrw6eCfUwKs3g31s8vlkUt N+tIwXrt8W1hLX6XAjVGmEGQ0gXAYNd2qdotPKMR5kHGQIuNa0YBytAWCUfjoFOi2RlA Tsv28FTE4c6kvCrFqbJCCbS+aacS85J3lLwkyecctvOzKpn+5Yn+tvzm6P61/XvRSDXU LPuxAzH260h3z86T1NXJh5o02nUt4LGW3lrwCL3GSxY1rPuay2jm79iN7f0Ed8dKX7T0 /gkii4kb8SFS3yp0W8ulKAw5to9pfnZKtKLiLlTHV27Zm7SLLNcUadrlwIaFWww80k5M Ym9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=0mpmQGLOHCWv4a89v9ZQ6gKDuog96KcaiiV2nx772Tc=; b=E1jA30fGLbyf2Un8E5YOJQX3MvFu2AkjFViJNZC2CrBEBAmqLGgKpLxXRz4lKplwQ3 D7LVVXTpMYedi6ImCZCJiJ+IfeiC/qkWf5/clqTTIKo/qchpPs4oYqLALpWiTfL0x7WO 56XATxIAzzs+8gEsfjHOrcLf/ZI2uGnfIxRQR/VYZrG1EHNhEINpZxpfzNBrughilPqS tAKzbZUyJv2AJb/W4NgQL6AbgFZE7hwcB/q0nv/L3UL3C1RQfzKBWrSwIjKZJlXIAmqv mMvw+l9umBJo61cUecKDmIU9H0ObWJIt/XobSMk80wMzrmsVkJLVjz6xDC2NJiVwznqm S/vA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jche9IaP; 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 a25si8279310pfo.80.2019.06.09.12.10.29; Sun, 09 Jun 2019 12:10:45 -0700 (PDT) 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=@kernel.org header.s=default header.b=jche9IaP; 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 S2388359AbfFIRDH (ORCPT + 99 others); Sun, 9 Jun 2019 13:03:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:41314 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732837AbfFIRDD (ORCPT ); Sun, 9 Jun 2019 13:03:03 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A836220843; Sun, 9 Jun 2019 17:03:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560099783; bh=v8jViTz1Qm/qg5OtQF+8F/At7QLvjzJgBcP9xOl6joc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jche9IaP6For1VhF8Wgz3KT/TDyCPUqymMMMQC9177ffj3tM1lCl1KULJUay2CECC aBRRQaGi36uW5hhqnhOoGgPPpq6/4R6Xj6QohCrvDGB3Ab3DEj61ntuNn5ejGJCdbm szsb5p4vD60sMBaAUQXlGFojl/Y4pOgU4TXpMxAo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Gustavo A. R. Silva" , "David S. Miller" , Sasha Levin Subject: [PATCH 4.4 164/241] cxgb3/l2t: Fix undefined behaviour Date: Sun, 9 Jun 2019 18:41:46 +0200 Message-Id: <20190609164152.508267997@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190609164147.729157653@linuxfoundation.org> References: <20190609164147.729157653@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 76497732932f15e7323dc805e8ea8dc11bb587cf ] The use of zero-sized array causes undefined behaviour when it is not the last member in a structure. As it happens to be in this case. Also, the current code makes use of a language extension to the C90 standard, but the preferred mechanism to declare variable-length types such as this one is a flexible array member, introduced in C99: struct foo { int stuff; struct boo array[]; }; By making use of the mechanism above, we will get a compiler warning in case the flexible array does not occur last. Which is beneficial to cultivate a high-quality code. Fixes: e48f129c2f20 ("[SCSI] cxgb3i: convert cdev->l2opt to use rcu to prevent NULL dereference") Signed-off-by: Gustavo A. R. Silva Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/chelsio/cxgb3/l2t.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/chelsio/cxgb3/l2t.h b/drivers/net/ethernet/chelsio/cxgb3/l2t.h index 8cffcdfd56782..38b5858c335a9 100644 --- a/drivers/net/ethernet/chelsio/cxgb3/l2t.h +++ b/drivers/net/ethernet/chelsio/cxgb3/l2t.h @@ -75,8 +75,8 @@ struct l2t_data { struct l2t_entry *rover; /* starting point for next allocation */ atomic_t nfree; /* number of free entries */ rwlock_t lock; - struct l2t_entry l2tab[0]; struct rcu_head rcu_head; /* to handle rcu cleanup */ + struct l2t_entry l2tab[]; }; typedef void (*arp_failure_handler_func)(struct t3cdev * dev, -- 2.20.1