lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240410135942.61667-5-afd@ti.com>
Date: Wed, 10 Apr 2024 08:59:33 -0500
From: Andrew Davis <afd@...com>
To: Jassi Brar <jassisinghbrar@...il.com>, Hari Nagalla <hnagalla@...com>,
        Nick Saulnier <nsaulnier@...com>,
        Bjorn Andersson <andersson@...nel.org>,
        Mathieu Poirier <mathieu.poirier@...aro.org>
CC: <linux-remoteproc@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
        Andrew
 Davis <afd@...com>
Subject: [PATCH v2 04/13] mailbox: omap: Move fifo size check to point of use

The mbox_kfifo_size can be changed at runtime, the sanity
check on it's value should be done when it is used, not
only once at init time.

Signed-off-by: Andrew Davis <afd@...com>
---
 drivers/mailbox/omap-mailbox.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/mailbox/omap-mailbox.c b/drivers/mailbox/omap-mailbox.c
index c083734b6954c..167348fb1b33b 100644
--- a/drivers/mailbox/omap-mailbox.c
+++ b/drivers/mailbox/omap-mailbox.c
@@ -310,6 +310,7 @@ static struct omap_mbox_queue *mbox_queue_alloc(struct omap_mbox *mbox,
 					void (*work)(struct work_struct *))
 {
 	struct omap_mbox_queue *mq;
+	unsigned int size;
 
 	if (!work)
 		return NULL;
@@ -320,7 +321,10 @@ static struct omap_mbox_queue *mbox_queue_alloc(struct omap_mbox *mbox,
 
 	spin_lock_init(&mq->lock);
 
-	if (kfifo_alloc(&mq->fifo, mbox_kfifo_size, GFP_KERNEL))
+	/* kfifo size sanity check: alignment and minimal size */
+	size = ALIGN(mbox_kfifo_size, sizeof(u32));
+	size = max_t(unsigned int, size, sizeof(u32));
+	if (kfifo_alloc(&mq->fifo, size, GFP_KERNEL))
 		goto error;
 
 	INIT_WORK(&mq->work, work);
@@ -838,10 +842,6 @@ static int __init omap_mbox_init(void)
 	if (err)
 		return err;
 
-	/* kfifo size sanity check: alignment and minimal size */
-	mbox_kfifo_size = ALIGN(mbox_kfifo_size, sizeof(u32));
-	mbox_kfifo_size = max_t(unsigned int, mbox_kfifo_size, sizeof(u32));
-
 	err = platform_driver_register(&omap_mbox_driver);
 	if (err)
 		class_unregister(&omap_mbox_class);
-- 
2.39.2


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ