From patchwork Sun Sep 8 06:52:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 826502 Received: from msa.smtpout.orange.fr (smtp-70.smtpout.orange.fr [80.12.242.70]) (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 CCC97A31; Sun, 8 Sep 2024 06:52:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=80.12.242.70 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725778345; cv=none; b=IqXSX9Paq5KyxfDAj05e45mPbkT+yqJabjeccBTFSRS3/eE74M3kIGX4uRJ7Ja0A/oW/W8YfsFKc7Jd1DJ9rhRJ7wfbZozKw+4L6dk+e5Txb/kKxaacykK6gzh3PpgOOkc5wLJfbLdnvxZ47IRojpQsKPB70qxV0jtr2rfGY3DY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725778345; c=relaxed/simple; bh=zPAg7VNhQvNNsfra+KnaQcSnvxjOSaUhSh5rAlZU1ac=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=lEdJmI3Fnr+dVQiHPYmgS0IWcb7scDYMA5Kb/H53tsBFBOkcDuwJWoZ06VntnJe8NaZAFheGcqO8BtAnNKMjSNAB5Ll2jXATRx2Uj0BXuuoizsXnm8cTJ+L2ZYg75QI2VkWHMpAVIPJ/JUyDjX3d0V0IUsCgoASsNOXDMV0pv3s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wanadoo.fr; spf=pass smtp.mailfrom=wanadoo.fr; dkim=pass (2048-bit key) header.d=wanadoo.fr header.i=@wanadoo.fr header.b=Am4E9osx; arc=none smtp.client-ip=80.12.242.70 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wanadoo.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wanadoo.fr Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wanadoo.fr header.i=@wanadoo.fr header.b="Am4E9osx" Received: from fedora.home ([90.11.132.44]) by smtp.orange.fr with ESMTPA id nBmTs6D2ClL4CnBmUs81fW; Sun, 08 Sep 2024 08:52:19 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1725778339; bh=wv3WFe0KxwUo6zf2E3vPHM9Wor5nA2RClGvCNFKZsVI=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=Am4E9osxNI8CqTI+8JwTgwxpCW+Gb/Fz0hzjEHGqO5wkkYbUgG29UOKphKF5zIWA9 lC0R1EmTIQI327JhyOBUoXFOX7HWcUmvQeZm/1nqJ80hUht5aYWJryno0f8YcuWjPf LPtg5QzluOjJhkddmJXqP+n9lvo+ObQmh0JwrfXSZSB4uSoZJf9MM1RkPt1Eduzzq6 BzijJZv/8tuaPDjF1dKyE32EatccHPMn89iMKVuJN5xMIFLR2xJyCRbxPJVpxxTIG+ MsWcJOBQA0xnusiZtgHr2w8LmMl2g6gkghHJ1QeBMwHPA+mfjyR7f9xpspijGV3E2A yj23vREDRk/oQ== X-ME-Helo: fedora.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sun, 08 Sep 2024 08:52:19 +0200 X-ME-IP: 90.11.132.44 From: Christophe JAILLET To: Viresh Kumar , "Chen, Jian Jun" , Andi Shyti Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , linux-i2c@vger.kernel.org, virtualization@lists.linux.dev Subject: [PATCH] i2c: virtio: Constify struct i2c_algorithm and struct virtio_device_id Date: Sun, 8 Sep 2024 08:52:07 +0200 Message-ID: X-Mailer: git-send-email 2.46.0 Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 'struct i2c_algorithm' and 'struct virtio_device_id' are not modified in this driver. Constifying this structure moves some data to a read-only section, so increase overall security, especially when the structure holds some function pointers, which is the case for struct i2c_algorithm. On a x86_64, with allmodconfig: Before: ====== text data bss dec hex filename 6663 568 16 7247 1c4f drivers/i2c/busses/i2c-virtio.o After: ===== text data bss dec hex filename 6735 472 16 7223 1c37 drivers/i2c/busses/i2c-virtio.o Signed-off-by: Christophe JAILLET --- Compile tested only --- drivers/i2c/busses/i2c-virtio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-virtio.c b/drivers/i2c/busses/i2c-virtio.c index 52ba1e0845ca..2a351f961b89 100644 --- a/drivers/i2c/busses/i2c-virtio.c +++ b/drivers/i2c/busses/i2c-virtio.c @@ -182,7 +182,7 @@ static u32 virtio_i2c_func(struct i2c_adapter *adap) return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL; } -static struct i2c_algorithm virtio_algorithm = { +static const struct i2c_algorithm virtio_algorithm = { .xfer = virtio_i2c_xfer, .functionality = virtio_i2c_func, }; @@ -237,7 +237,7 @@ static void virtio_i2c_remove(struct virtio_device *vdev) virtio_i2c_del_vqs(vdev); } -static struct virtio_device_id id_table[] = { +static const struct virtio_device_id id_table[] = { { VIRTIO_ID_I2C_ADAPTER, VIRTIO_DEV_ANY_ID }, {} };