From patchwork Mon Mar 4 16:04:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Lechner X-Patchwork-Id: 209624 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6359:6299:b0:17c:1df7:5ed3 with SMTP id se25csp288064rwb; Mon, 4 Mar 2024 08:08:00 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXzMpj9SSvWtxf4jJHWezukjYiHFXgiRMNE3EVw6qEbwPwXOf0eeU88k0LIzLvl16EuhkDtO9asStfKvflMyAJufZHSew== X-Google-Smtp-Source: AGHT+IH9/eIWZKYv1gqp/VC3nlNc3V7/Xu3+Y0gEjb4ehu603ln1AqHpZCRgFab1IJRs5Lt84T8c X-Received: by 2002:ac8:5c55:0:b0:42e:752d:f3bd with SMTP id j21-20020ac85c55000000b0042e752df3bdmr13656705qtj.27.1709568480021; Mon, 04 Mar 2024 08:08:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709568480; cv=pass; d=google.com; s=arc-20160816; b=h8MykUZzhppdOi+j2QRvcDCaB0JGWVoA4Z4XMIB4sQrM6UbiuzH2u/rIVAB8QGjCof mom8mZiYwZsYbTceq/CshqmaWHnEJNJebRjfJFT6DEYO0oJBgRno3D24L0XfWxXmtY7M oYoxlqoUKqodNLfG2xALJO2J0+nzw8TwmfDknbMmsTXA1Yqw7+m9WznTAT+RcV/hb7IN YO8yVObhW0SmrTkxWqYt5rIbQKmz6/aWp/L2JX+36diKzrepM8bunKkk9WBfzzW3TWLh HvTHDDcSDt1DkRVPsbam1opTiY+KqVE5m2+C8Jv/RDBwMKlmCWbLRYPK4QGKdOQ89KhO 4N3Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=47S4ZgnBYo9jKRg+1Qx0IpWuTU4W29awdHsHBhIR8G8=; fh=6WeVAHeQ5VExt2/5hyeplFIQ9gLoU1qeisIFGmXVImE=; b=kSdFyEBXhP3XeREsle+lgEeciMrsOnqyQtWQwDh98ivmNHma885MTPaDqapTDr0UVo TVIh1jA+iAIPhUtKfzd+PcmkN4Rydp0rOmezKIR1Ishi51bMafQ43cjWDC9JqSKyQDxj avnwinF5eTT2MuJc3xlCQ7y2LG55pDxgcNxpfZkXM055kh5884Fv+eHUaexgABFgKpV4 EzIePSfHyVXZLrKtdFmKMy/neQMDw+gnBYRO/phyAGW9czG0Ax/W/Ogq+2vBH79GSs4e tADG/WmxT/MNASvmgPDRgXQK+7PmrRsuT2t57XNUiXuK5MHLEsBypPvwu39gWKRUwl21 CrEA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=ojILu51K; arc=pass (i=1 spf=pass spfdomain=baylibre.com dkim=pass dkdomain=baylibre-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-90902-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90902-ouuuleilei=gmail.com@vger.kernel.org" Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id f11-20020ac859cb000000b0042ee13a9e58si4839297qtf.39.2024.03.04.08.07.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 08:08:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-90902-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=ojILu51K; arc=pass (i=1 spf=pass spfdomain=baylibre.com dkim=pass dkdomain=baylibre-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-90902-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90902-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id D3AB81C2128D for ; Mon, 4 Mar 2024 16:07:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 30C7D4EB51; Mon, 4 Mar 2024 16:07:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="ojILu51K" Received: from mail-oa1-f44.google.com (mail-oa1-f44.google.com [209.85.160.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 33624482EB for ; Mon, 4 Mar 2024 16:06:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709568418; cv=none; b=SgHv+sBM1hLg2Ce0WkUhSOyjq1Nm2Geg/2RHpx48JctYbT5Anm4jMWoLuoVBLIEsZLDzXn0rGnikZ2pjHaU097WGBYVLjT1B3eK/Rov4jsNIlGlXqoEzWBbL9oLoaQ7ubeYgnC2VIyDWktuvKvlk6iqCFCghQ7X1uDH3gH8iyiY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709568418; c=relaxed/simple; bh=5hT5wjsUvej4t0PzrwkFZZddS5utw/QYaLNNX9eOC0g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=AXQouBLPb+gY1cPBuCXjrhHC5XA+MckuvVfTwNyKg0AxA3OZgyvJbJHinSeB742UyQvJ9JDtj8t3Pe5xfxCwFp9/w6fB63nFWKbI1gHODZtEC+sJ4KWtaoeAe2VpGnQvPUvG5CnZLUZGXkMVSDfCoUecYjLvLNCmLPpPzDL1cnI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=ojILu51K; arc=none smtp.client-ip=209.85.160.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Received: by mail-oa1-f44.google.com with SMTP id 586e51a60fabf-2210865d962so911718fac.3 for ; Mon, 04 Mar 2024 08:06:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1709568414; x=1710173214; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=47S4ZgnBYo9jKRg+1Qx0IpWuTU4W29awdHsHBhIR8G8=; b=ojILu51KDxcLa8wt1MuvwAZ2zY0s/ZInPDn+TrUK5FsoZzwbXRJdUlVEgu9z4czUXm /XNS6Eyqxw2xa11MkN2Fn8w1mJdPgPqTH2NWyrNGddt8UjFpB8si9zCM9xVY52D3VMYY rWTA7E5TXy89VWoBTs5KmQkkkkKwMZYYEmR2K37Xy4o/t7JEMtqCkqtCFahzYYfBnkQp 3zK6rfVRLI0yzWsZ1KLlGTQ9F3RLoXYAdvQm/r/FEosbIFN4NUPfnzwsWjz4+7LGxYpM 0s0DKqrfF21G1/xVQ89lbHPuIG9JqV7oUtTAorFMyEAF5LtEXzrnDqr62iT2RORfUlm+ Hj9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709568414; x=1710173214; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=47S4ZgnBYo9jKRg+1Qx0IpWuTU4W29awdHsHBhIR8G8=; b=uA/uE1KqiGroRDWsKlZev4oHzWG8CgOdR7V82CGirehHT0QiinoDfkaSZpi41nkKXk P05psFZhOkrdSloYgHO0TP4v+FN7ao8Z/IF5FGYGQ+a75QwIm5xXU7nPeyEOChq+yqQA L6ubwQAIA8u1maDbKdrRVIfArvURTFNUAv5Twc6D/tii7Nzvt9vX6BdbSv7H7J+n7En2 0UfRY+4S8GNa5Axiw7DHhNfI1NuNzuL+UdpehQVePV0Ip0wVypSEZMrOJ1X3HXxFzgok 0dI79VwYqW6lZJspfFXAiubJ6tehn8VMaJHmDkP3Xf73ZAXCPNKcHccMPya33Uex+q0W XK/w== X-Forwarded-Encrypted: i=1; AJvYcCUG2MmtlZ1tKa55ax4zIpsu6RQc6j4FzSx96DNlJRwnlS+toWO3gc7HrUrIQg3s+E3uWMRA2xGiF3DZmXAzfxiQHA1IZ5qOy7eTZYGc X-Gm-Message-State: AOJu0Yw6T47+t4Sxt92b2LvduGL+pJocj3KeFp7jY/0IV9f4dIEVJXcb vv1ZONTEsgMHH4Bi6DNcV8HTCYeynp9ikKjbrDaNZun27ShHR0guUA1S2zbahyo= X-Received: by 2002:a05:6870:37cd:b0:220:9862:a2dc with SMTP id p13-20020a05687037cd00b002209862a2dcmr10440444oai.57.1709568414246; Mon, 04 Mar 2024 08:06:54 -0800 (PST) Received: from freyr.lechnology.com (ip98-183-112-25.ok.ok.cox.net. [98.183.112.25]) by smtp.gmail.com with ESMTPSA id lu6-20020a056871314600b00221287ebd03sm83392oac.4.2024.03.04.08.06.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 08:06:53 -0800 (PST) From: David Lechner To: Mark Brown Cc: David Lechner , Michael Hennerich , =?utf-8?q?Nuno_S=C3=A1?= , Kees Cook , "Gustavo A. R. Silva" , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH v2 1/3] spi: axi-spi-engine: remove p from struct spi_engine_message_state Date: Mon, 4 Mar 2024 10:04:23 -0600 Message-ID: <20240304-mainline-axi-spi-engine-small-cleanups-v2-1-5b14ed729a31@baylibre.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240304-mainline-axi-spi-engine-small-cleanups-v2-0-5b14ed729a31@baylibre.com> References: <20240304-mainline-axi-spi-engine-small-cleanups-v2-0-5b14ed729a31@baylibre.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.12.4 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792612478725504875 X-GMAIL-MSGID: 1792612478725504875 The program pointer p in struct spi_engine_message_state in the AXI SPI Engine controller driver was assigned but never read so it can be removed. Reviewed-by: Kees Cook Signed-off-by: David Lechner Reviewed-by: Gustavo A. R. Silva --- drivers/spi/spi-axi-spi-engine.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/spi/spi-axi-spi-engine.c b/drivers/spi/spi-axi-spi-engine.c index 6177c1a8d56e..d89f75170c9e 100644 --- a/drivers/spi/spi-axi-spi-engine.c +++ b/drivers/spi/spi-axi-spi-engine.c @@ -82,8 +82,6 @@ struct spi_engine_program { * struct spi_engine_message_state - SPI engine per-message state */ struct spi_engine_message_state { - /** @p: Instructions for executing this message. */ - struct spi_engine_program *p; /** @cmd_length: Number of elements in cmd_buf array. */ unsigned cmd_length; /** @cmd_buf: Array of commands not yet written to CMD FIFO. */ @@ -543,7 +541,6 @@ static int spi_engine_transfer_one_message(struct spi_controller *host, /* reinitialize message state for this transfer */ memset(st, 0, sizeof(*st)); - st->p = p; st->cmd_buf = p->instructions; st->cmd_length = p->length; msg->state = st; From patchwork Mon Mar 4 16:04:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: David Lechner X-Patchwork-Id: 209628 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp1525713dyc; Mon, 4 Mar 2024 08:18:22 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW/MFsVDjwtmDMzSvflHG59CDlpsG+xvCXFN6I6pWHt5uAGrLkPcnhsW5LAZ3eXZY/C8B+tyhfnjv/cTSVwb5Pvf9wwcw== X-Google-Smtp-Source: AGHT+IHjK62zhOSfD3OG2cR/avlBH2bgdtWmFKtyL3t9E2tKPM9d5/xXWRPygPY5I+YFv3QDwhIR X-Received: by 2002:a05:6a20:e608:b0:1a1:568d:b4eb with SMTP id my8-20020a056a20e60800b001a1568db4ebmr934005pzb.39.1709569102156; Mon, 04 Mar 2024 08:18:22 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709569102; cv=pass; d=google.com; s=arc-20160816; b=DLn2KXsizuYqfN4WTebopK+03/KGV8Y3eTWRXMwVz9xJ3LKUrmppgumlL89bG3SmuG E1x7MD5t8e/yeqHsrYViJhRvK3vR5Q/wVHNglkNeMaTKoWcMrycpxgQ40DQhKbNctOJA zKbSapBwUDr+NJ8X1xnssFRc+Ps6dDR822LQwKKLEHNcl8fDPOuKSuxt9eJA2y/WvdbW Zu7LslSs9wLsgv90Eecq8+svNKpVEMWWxQpgIhSlB5CofyVp8r5sUZsTk4g3oRXsIbWw TUL5JAAtbcV4YSePY7bjl97eqJERQBdJnqghXJBjet+b15+R/lUgShKi9hTHH04uacG+ epSg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=JCP8eJQPKeVzox/Qa6ATJPu9ofpJI+UjARSHWwbkYKs=; fh=E8Ig0C35BcRQBXxQQXIUp/23W4GaAxUZxsJgnSUhVe0=; b=0oAJ0zekWzVKNmEvf2V/J1Gd9f/2sEmwsSZJ65w5MmAZ9cnydYIm9+2xauwWPNkLzx DfaeZjwuJVvgyXVh2BJ6GOrBzxfu1VMjLGZsVme7H3OUlSMPE5ozCbhOv9Vp0PHOQlAc xDtcS3mnx+bscFAsmP1afkzKTK2GOt9vWXgJoWDhkP/ATS7lUbuVbLKoMM8nzk/L+teQ u1UA/UUgLcae8NVfIAGw3FFyKhJ/V3yb7uBzW0wm+/qkj0kATgExp/hoFxwkH3FiyrQS DnURRUTR0T47AJMBeoJ9F0CNxDWFaUUEWhuviGWqFfQveLgm3LkVS3ZR2gmnOzxsN+n6 oLrg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=kMgmySUD; arc=pass (i=1 spf=pass spfdomain=baylibre.com dkim=pass dkdomain=baylibre-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-90901-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90901-ouuuleilei=gmail.com@vger.kernel.org" Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id p4-20020a056a0026c400b006e4da39134dsi8394119pfw.28.2024.03.04.08.18.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 08:18:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-90901-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=kMgmySUD; arc=pass (i=1 spf=pass spfdomain=baylibre.com dkim=pass dkdomain=baylibre-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-90901-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90901-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id B49192826D3 for ; Mon, 4 Mar 2024 16:07:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 404744C618; Mon, 4 Mar 2024 16:07:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="kMgmySUD" Received: from mail-oa1-f48.google.com (mail-oa1-f48.google.com [209.85.160.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F3107482D3 for ; Mon, 4 Mar 2024 16:06:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709568417; cv=none; b=Xu75FYJwMSlLjeoyfNJfbDzs9WNF0uRgevARCIVo3FLWq0tUMvkd5gv3uTvtPio1fUbLblgpsOYjaHcLFO3F9kce3Foqv/xwpsnr6nHSqI7Qe5mxUsUWaCgpfEbceC/BCRJqkwJanHmpdazer0O4WOM0GbVopWv5XMPN28T7HhU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709568417; c=relaxed/simple; bh=Iov+SLQtBZ5UAEb6YDKr9rdAOJnCjM7+0r7ET3OF5dA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pMBtEKjqaC6TVF1/6fr7mZxt/i86IxVnd6ZECD/QpF9CeU/BBZ6CaMW17xPP2Ffhz6E+celfnR7K7uH6OpB/0LvGLRHz5uajRTMXIahL82l6at2VyZiL5zcHeTqwR/hoGbhXVpHy8X80mmEGiMO/LcEaTQK8bcAZRMJy5IR3y0g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=kMgmySUD; arc=none smtp.client-ip=209.85.160.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Received: by mail-oa1-f48.google.com with SMTP id 586e51a60fabf-21fa6e04835so1505894fac.1 for ; Mon, 04 Mar 2024 08:06:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1709568415; x=1710173215; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=JCP8eJQPKeVzox/Qa6ATJPu9ofpJI+UjARSHWwbkYKs=; b=kMgmySUDd6O8PX8aZH+RTbu1pDkEu0602rzF0RZRHJsRu4qGQNunJnnXLtipR3zewS wudzqWiofmjMNNUVMgtY7Rsx1WWgVagTE0fMDXzme2u3vIfkKxhlvA5cqi7c0lXA26uN y0clrAfkJneiS9oRsotjBlVGooQslWkaqL9N0aFqCfHhSzLtDUsRtGnbMuoFBtBQxckU ycpLLjNCitB39uZRl6Ga/3ZFfnuird0GXYSPffj5taiyqoWVAgVtrnChW5VmbdAXkdoP /kQz/bEgW1xySjiGu4oW7LeFAxZOu5M3a+b2ZMDC8fUkInSLsvhEInoAjJ0u/dDt9Ms6 OMDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709568415; x=1710173215; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JCP8eJQPKeVzox/Qa6ATJPu9ofpJI+UjARSHWwbkYKs=; b=X7VdAyfjeYNkFBlIv8UQ7tSLqMOmCsv/7N67dWPZ0fLVkGu6XCoSd+RUtKcIT92d38 fMAiWHYkc6VwjZGp2H9zaWFIbsLpD+X7gSa24k0kSmzzcI9Apzj1mY5oFbqpR5vU/ngF Cy4eNtyE+Qz0+JxRvf0aXPBtsQqED6Vu4Vw2Vm57gVW4Au06YXErO+vWbcSHNrw1GNVy oragYp54LqpBfgVv6VJAOHZm3CCqGJOgVOSDnFB6b82SOt7DxLB4He2FbiEAfB90BFV/ YNEL31IaEeCMPxv3kOk2bjgpl1TqKtdNUV5SL+4H6UqyQAeS0Xbsta1iAonQaPuB5kFE Cy2A== X-Forwarded-Encrypted: i=1; AJvYcCWDl10pYT/235C8vAhDpbZ1AoBQqmujHfSENIQjvRKjG7gmeEz2OMSkpT19AZ8hiCDBr8iduHcLUiqisZeOApQig/0gRtFUWsu52iUe X-Gm-Message-State: AOJu0YyAmjsZQRnfrq8X4GODRCyWfZvJl97NQEPVr2p/klPs+ZjuPJ9Q crZcdCY1990kb40sk3kqvWRxGhdSulUd0ItXT8yxvxORTANlueBZVw/TRn0NvYI= X-Received: by 2002:a05:6870:b526:b0:21e:8afd:65d0 with SMTP id v38-20020a056870b52600b0021e8afd65d0mr10111952oap.52.1709568415111; Mon, 04 Mar 2024 08:06:55 -0800 (PST) Received: from freyr.lechnology.com (ip98-183-112-25.ok.ok.cox.net. [98.183.112.25]) by smtp.gmail.com with ESMTPSA id lu6-20020a056871314600b00221287ebd03sm83392oac.4.2024.03.04.08.06.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 08:06:54 -0800 (PST) From: David Lechner To: Mark Brown Cc: David Lechner , Michael Hennerich , =?utf-8?q?Nuno_S=C3=A1?= , Kees Cook , "Gustavo A. R. Silva" , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH v2 2/3] spi: axi-spi-engine: use __counted_by() attribute Date: Mon, 4 Mar 2024 10:04:24 -0600 Message-ID: <20240304-mainline-axi-spi-engine-small-cleanups-v2-2-5b14ed729a31@baylibre.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240304-mainline-axi-spi-engine-small-cleanups-v2-0-5b14ed729a31@baylibre.com> References: <20240304-mainline-axi-spi-engine-small-cleanups-v2-0-5b14ed729a31@baylibre.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.12.4 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792613041650890195 X-GMAIL-MSGID: 1792613130718024148 This adds the __counted_by() attribute to the flex array at the end of struct spi_engine_program in the AXI SPI Engine controller driver. The assignment of the length field has to be reordered to be before the access to the flex array in order to avoid potential compiler warnings/errors due to adding the __counted_by() attribute. Suggested-by: Nuno Sá Signed-off-by: David Lechner Reviewed-by: Kees Cook --- v2 changes: * Reordered assignment of length field. --- drivers/spi/spi-axi-spi-engine.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/spi/spi-axi-spi-engine.c b/drivers/spi/spi-axi-spi-engine.c index d89f75170c9e..a8f626165f44 100644 --- a/drivers/spi/spi-axi-spi-engine.c +++ b/drivers/spi/spi-axi-spi-engine.c @@ -75,7 +75,7 @@ struct spi_engine_program { unsigned int length; - uint16_t instructions[]; + uint16_t instructions[] __counted_by(length); }; /** @@ -115,9 +115,10 @@ struct spi_engine { static void spi_engine_program_add_cmd(struct spi_engine_program *p, bool dry, uint16_t cmd) { - if (!dry) - p->instructions[p->length] = cmd; p->length++; + + if (!dry) + p->instructions[p->length - 1] = cmd; } static unsigned int spi_engine_get_config(struct spi_device *spi) From patchwork Mon Mar 4 16:04:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Lechner X-Patchwork-Id: 209626 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6359:6299:b0:17c:1df7:5ed3 with SMTP id se25csp289934rwb; Mon, 4 Mar 2024 08:10:35 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWjXN14FvU2RIi8nSteawzZh40vM5xm4bwFqCzasWC/BvKcd7LGrnUQQoGTkrKql7moK511H+aK/SaFOIyFeeXrCcGCcw== X-Google-Smtp-Source: AGHT+IEkQE6waMBGHMyWR6xB4E0uXIinQH+Z8RENss9HITfVknJtKi1kzDAhGb/QcU+4vMIDD43v X-Received: by 2002:a17:906:6813:b0:a44:51d8:7dd with SMTP id k19-20020a170906681300b00a4451d807ddmr6700392ejr.0.1709568515761; Mon, 04 Mar 2024 08:08:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709568515; cv=pass; d=google.com; s=arc-20160816; b=1AR7g2rc9FiDypwh9aYzFmbr8GJybvwBGYzHioI2SAjpc5T5fQZ8eMSumHz4muRew8 IunLIbv1I18Kq4paybnk1l9DaCCQ4hQ0Qw35bRuuJb9O7KWl8hOhz4uedGanmG3UTFtl 0qx5it2JnotXQDMfYwSK3R1fBZ5QhwYO9t2cyjHO1+bD3ArkQswCOTf/Pn+m7b3cu6ll uEj5/vfPpJ5e9lSKJobqDx7MGklP+GDm5jVnOba3HcYOAb/QgauQtSG9FL/IafZHc++n x96F54PUrjnDNMTe8eiahZM7MlWh7Eh2BJotYfsWzQSYS+lG/IBuU/yX68bVvGLb7TiR 98QQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=yn3BxlJjgBPLtIhw8+vZTdHKWgVz7bubHMhhj+7dA28=; fh=qAZ+oxz+kXXPwm9obFNSTZKp1Kf1HsptXy6ok7muTJc=; b=QiPTxpvk6Ud7H/Gfk+k+y8n5xGstw+vGRqQwziR1zY0exOjrcuiKp4VMOetsW1in8t Sz2yhYENuD4L2fBrY6ajFWuSkj6kF4OhSV2C89fcFmVJnk+6IelaTxLUHmOU4bBRUdML Y0AtjOBw1ybynqAD5ie1ML+RedcehgoFT/41xn0gEQKRlba2Dt0NI3v3AQvVd4oNg4cA YLzXbHLRYPw09oxSi5nys+NwIUYL7Fxqx7LIHEZmwuaA6TnI4oX44E20wQER1jsn4HVs s9L9IStp1gfYwxzKpGUvpDd7R951VIElZA+cjp6PYEEddCLxHeKi1z+41FZgxIQ75cZk p/sA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=HIh9XJsY; arc=pass (i=1 spf=pass spfdomain=baylibre.com dkim=pass dkdomain=baylibre-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-90903-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90903-ouuuleilei=gmail.com@vger.kernel.org" Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id qw9-20020a1709066a0900b00a3f48c22b50si4328196ejc.160.2024.03.04.08.08.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 08:08:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-90903-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=HIh9XJsY; arc=pass (i=1 spf=pass spfdomain=baylibre.com dkim=pass dkdomain=baylibre-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-90903-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90903-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 42A731F231A6 for ; Mon, 4 Mar 2024 16:08:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 30C374EB3F; Mon, 4 Mar 2024 16:07:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="HIh9XJsY" Received: from mail-oa1-f53.google.com (mail-oa1-f53.google.com [209.85.160.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B45AF487B0 for ; Mon, 4 Mar 2024 16:06:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709568418; cv=none; b=mN5adOE5T4O1LM1G7Zv9FxGsfpgP31fd6NhYOhzqbXhjcoyacEFmmF3HVe48MEBGGdzZgVZmENgwWM62L8Rfva0GNNoA2BLfK93eeXcsVeIELd+e0GX+mpzgHG/cpLw0mzCdwL1GBTmKDZWc1+o8NNyyh7Ytm+istDLhXnZCgiw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709568418; c=relaxed/simple; bh=HDTEIEeTth+YlarlZwpbtqNSffqitQLrinmgPBP7yu8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=OpU9UR5tQLrmZYVkDIYMIgrPVW16wxuVgT5stO5clZqdaQXLC/E7GZTXkMQ5iUwHcUFdfdEY/4cuCAlYjqSGrR5vPY62p0j65Q1BZDjyeOjkuze8zTLIzWEt8OELXLGtyArTNFFdcz9m65NpujykAzEi1iaHzhMuEAAQI1MWsRw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=HIh9XJsY; arc=none smtp.client-ip=209.85.160.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Received: by mail-oa1-f53.google.com with SMTP id 586e51a60fabf-21f5ab945e9so2306817fac.0 for ; Mon, 04 Mar 2024 08:06:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1709568416; x=1710173216; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=yn3BxlJjgBPLtIhw8+vZTdHKWgVz7bubHMhhj+7dA28=; b=HIh9XJsYBqEMYRZ8eqTP1tlbkwygZg35Z15NyWUUL9pqFI+K7BC8nxqaRJCUP4bTYa fJNFOGfr89S6ZL1dr12WqBLdhoRmjg0PRO0L/Z/tc5HgQB0DA59XtGE5yZKpLjA720Ll kTNbBKV90lMMKndvzQ1EJU5DFWuP4+mZ+UivCTHTfN2yywKjzrNayUQh/+JfvQeQYHO3 tdlRTiY6oiycYraN+2Pa97OQEmeseynPpZ6Zk2HfrkQ/Hij0uByIY0JQivFE0eVqJnUo geRetPZWlRrrs22mfqNq862Lw3xhLMKRbg4K9Dg/1zkvr3BVU/X37m3NOYBtGT7c5ixA GXag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709568416; x=1710173216; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yn3BxlJjgBPLtIhw8+vZTdHKWgVz7bubHMhhj+7dA28=; b=BNjVU2CHtMWAzYZWlt+/jC8MOWwAmb6lQwspv+KIN+UdyJc4t/gIZbrr4ovqIpg7Op E7uoHGC3/MktCvliY2Xgc+Q/aze6kmon3maRIlowaC3U/obb6LQz5nOFvxC3hX3vfOYK FtP5olCHSATz0Ufhm5j9A6uEa2LOc46OJrP1qspL2iRQ6cZLL6gVSysKNvxi2awybHC0 ijuIf3ZWs8qxqeLvSOn/4fNpPMejkeUn4HGju4UwNm/TUOXMH2aleITpRyVe4wgwK/Gb N6w+Lm+iplQq2AFzuPUm8ujKKAIEdbdkxXgjG4HdD7HH78bpJc1s0jp4SKxGVl75/DsH Vlxw== X-Forwarded-Encrypted: i=1; AJvYcCVuCbdpnGsDkHwicNvX+Y1q4qXBBUuoO6vJ7lVbrF4OnwwmTxQWDlRLyovkFsTB2r84uu+hkFZT4nN5OPwTK1F7tjFW4W6zBDxHP43Y X-Gm-Message-State: AOJu0YyV53VLzLzYbbXS/1ViXQh2wxbzBxbchxWjCzxXR5PODPCXVFou tydhZ7RgjistIMRmFSTysWFNRMeNiotGw7pNKtmnDqlHCcL7wDttTzAgkIgDhV8= X-Received: by 2002:a05:6870:55d2:b0:220:c434:385b with SMTP id qk18-20020a05687055d200b00220c434385bmr4105937oac.0.1709568415975; Mon, 04 Mar 2024 08:06:55 -0800 (PST) Received: from freyr.lechnology.com (ip98-183-112-25.ok.ok.cox.net. [98.183.112.25]) by smtp.gmail.com with ESMTPSA id lu6-20020a056871314600b00221287ebd03sm83392oac.4.2024.03.04.08.06.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 08:06:55 -0800 (PST) From: David Lechner To: Mark Brown Cc: David Lechner , Michael Hennerich , =?utf-8?q?Nuno_S=C3=A1?= , Kees Cook , "Gustavo A. R. Silva" , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, Christophe JAILLET Subject: [PATCH v2 3/3] spi: axi-spi-engine: use struct_size() macro Date: Mon, 4 Mar 2024 10:04:25 -0600 Message-ID: <20240304-mainline-axi-spi-engine-small-cleanups-v2-3-5b14ed729a31@baylibre.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240304-mainline-axi-spi-engine-small-cleanups-v2-0-5b14ed729a31@baylibre.com> References: <20240304-mainline-axi-spi-engine-small-cleanups-v2-0-5b14ed729a31@baylibre.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.12.4 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792612515897856587 X-GMAIL-MSGID: 1792612515897856587 This makes use of the struct_size() macro to calculate the size of the struct axi_spi_engine when allocating it. Suggested-by: Christophe JAILLET Reviewed-by: Kees Cook Signed-off-by: David Lechner Reviewed-by: Gustavo A. R. Silva --- drivers/spi/spi-axi-spi-engine.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/spi/spi-axi-spi-engine.c b/drivers/spi/spi-axi-spi-engine.c index a8f626165f44..7cc219d78551 100644 --- a/drivers/spi/spi-axi-spi-engine.c +++ b/drivers/spi/spi-axi-spi-engine.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -502,15 +503,13 @@ static irqreturn_t spi_engine_irq(int irq, void *devid) static int spi_engine_optimize_message(struct spi_message *msg) { struct spi_engine_program p_dry, *p; - size_t size; spi_engine_precompile_message(msg); p_dry.length = 0; spi_engine_compile_message(msg, true, &p_dry); - size = sizeof(*p->instructions) * (p_dry.length + 1); - p = kzalloc(sizeof(*p) + size, GFP_KERNEL); + p = kzalloc(struct_size(p, instructions, p_dry.length + 1), GFP_KERNEL); if (!p) return -ENOMEM;