Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp270829ybi; Wed, 29 May 2019 21:05:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqy1rCbhuIKM/jhNLDVIZu1kBW6ChXOCpIsQr7QPcUMS1liborVFjou4ChOpxqPtg4MYOHd6 X-Received: by 2002:a65:5304:: with SMTP id m4mr1852447pgq.126.1559189110139; Wed, 29 May 2019 21:05:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559189110; cv=none; d=google.com; s=arc-20160816; b=pOCpYhtx42lhb3q+VTRnx0mBI9CNwxPyya6J/R7Dn4cNZdr9ASbsmE0S3xsjyYAGw3 DN6fwx0O8NstGun1FFHhmj9+DpAVcKFwh3RMus49hiHOxqwfHjXCjLueiO2hPve7uJq8 g54Gc39HaRuiDSE3QqKfy5GbG7rq1wczhyhKp9MJvOLfakkh93FZtmJweu8DuOmzzaU/ rFFTpfVlR1d24jY+/4t40ys4UuRr+GZI3UdGlwtRGS9cyBu5TaJCwqt2WBr8SuMFia88 VN4lPBp0uGE+PnOMhifmHjBJqRMM9YAmH6XHnPVtDfqBn/rHhK+w/egEg8AtyfouO/kO Yvpg== 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=DjCj5NP/oxUwH7bRJKwaSQcfrGyYevqtGXJMBE5bbg8=; b=WhghxTTHoPr0HTe/h1Ud/CxG9tG+JeR06ffwOu0RgpvCprr905sqB+/OAsxUZD1DMO 30SL7sHuYd6VpodaInJejmtuaUzqBcUx4JBGBUoFaX/6+am3y+Wbu8xhEpu7e6JwKTM2 UVU+x731pl7D6JhiwMgnozC+RJVMpJdXyeESxcTdiIGGiRGtiNq4sdcGXgqcukR7aPb4 mwin5SHJsF4UqkAoMETHDEnI1GyY1wJz4G0D+m2MCyxlc29r+YdTUaQCbJuqeCS1RCgU fYZBuFu0NC3FMT2DevNwpWjzwDEI0uPXJ1djxa85FNUskdDA2DVgexBzi1xM5Jz3BofW 42tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ZkoTca97; 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 q73si1686783pjq.89.2019.05.29.21.04.54; Wed, 29 May 2019 21:05:10 -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=ZkoTca97; 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 S1731681AbfE3EDp (ORCPT + 99 others); Thu, 30 May 2019 00:03:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:49154 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731336AbfE3DRz (ORCPT ); Wed, 29 May 2019 23:17:55 -0400 Received: from localhost (ip67-88-213-2.z213-88-67.customer.algx.net [67.88.213.2]) (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 95FE62465C; Thu, 30 May 2019 03:17:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559186274; bh=DVF2BsjhTgYxFfpTkGy6e03bpwNSrsgVjaDEudMpCwE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZkoTca978pLaI8GT1F0W7SKSVRSjnDQbPRAa/sB39m4gwLcFx9noPoQKxEzyY/Lfb zf8bwl76pivwY2fh6N4TIqa5EKe+4fUdPmLa+/HN4PZsgDLO+xiqcSGScfaVh68cQd +mHJUrPXV1typGibKUBf43OhAWvzc6Oqw64npQJY= 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.19 216/276] cxgb3/l2t: Fix undefined behaviour Date: Wed, 29 May 2019 20:06:14 -0700 Message-Id: <20190530030538.634682418@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190530030523.133519668@linuxfoundation.org> References: <20190530030523.133519668@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 c2fd323c40782..ea75f275023ff 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