mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Will Shiu <Will.Shiu@mediatek.com>
To: <stanley.chu@mediatek.com>, <linus.walleij@linaro.org>,
	<matthias.bgg@gmail.com>, <linux-gpio@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, <Will.Shiu@mediatek.com>
Cc: <wsd_upstream@mediatek.com>
Subject: [PATCH 1/1] Pinctrl: Add in zero check
Date: Tue, 16 Aug 2022 17:09:03 +0800	[thread overview]
Message-ID: <20220816090903.19558-1-Will.Shiu@mediatek.com> (raw)

add in check of buffer offset to avoid the exception when input 0 size.

Signed-off-by: Will Shiu <Will.Shiu@mediatek.com>
---
 drivers/pinctrl/pinmux.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c
index f94d43b082d9..646dff591b21 100644
--- a/drivers/pinctrl/pinmux.c
+++ b/drivers/pinctrl/pinmux.c
@@ -689,6 +689,9 @@ static ssize_t pinmux_select(struct file *file, const char __user *user_buf,
 	if (len > PINMUX_SELECT_MAX)
 		return -ENOMEM;
 
+	if (len <= 0)
+		return -EINVAL;
+
 	buf = kzalloc(PINMUX_SELECT_MAX, GFP_KERNEL);
 	if (!buf)
 		return -ENOMEM;
-- 
2.18.0


             reply	other threads:[~2022-08-16  9:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-16  9:09 Will Shiu [this message]
2022-08-25 12:06 ` Linus Walleij
2022-08-25 12:17   ` Andy Shevchenko
2022-08-25 12:19     ` Linus Walleij

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220816090903.19558-1-Will.Shiu@mediatek.com \
    --to=will.shiu@mediatek.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matthias.bgg@gmail.com \
    --cc=stanley.chu@mediatek.com \
    --cc=wsd_upstream@mediatek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®