From: Nitin Gupta <nitin.gupta@samsung.com>
To: Arnd Bergmann <arnd@arndb.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Shivnandan Kumar <shivnandan.k@samsung.com>,
Vidushi Koul <vidushi.koul@samsung.com>,
Gaurav Kohli <gaurav.k6@samsung.com>,
Rajat Suri <rajat.suri@samsung.com>,
Shailesh Pandey <p.shailesh@samsung.com>,
"shiv.jnumca08@gmail.com" <shiv.jnumca08@gmail.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Fwd: [PATCH] char:misc minor is overflowing
Date: Wed, 09 Dec 2015 12:51:33 +0000 (GMT) [thread overview]
Message-ID: <1925385281.482851449665491986.JavaMail.weblogic@epmlwas08d> (raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=windows-1252, Size: 2806 bytes --]
Hi,
Is there any modification / improvement needed in this patch ?
------- Original Message -------
Sender : Shivnandan Kumar<shivnandan.k@samsung.com> Engineer/SRI-Noida-Advance Solutions - System 1 R&D Group/Samsung Electronics
Date : Nov 20, 2015 15:35 (GMT+05:30)
Title : [PATCH] char:misc minor is overflowing
When a driver register as a misc driver and
it tries to allocate minor number dynamically.
Then there is a chance of minor number overflow.
The problem is that 64(DYNAMIC_MINORS) is not enough
for dynamic minor number and if kernel defines 0-63
for dynamic minor number, it should be reserved. But,0-10
was used for other devices, for example 1 is reserved for
PSMOUSE. I got the issue that misc_minors is 0x3FFFFFFFFFFFFFFF
and so, value of variable 'i' in function misc_register becomes
62 and so misc_minors become 1.(Which was already reserved
for PSMOUSE). This patch help to avoid the
above problem.
Signed-off-by: shivnandan kumar
---
drivers/char/misc.c | 5 ++---
include/linux/miscdevice.h | 1 +
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/char/misc.c b/drivers/char/misc.c
index 8069b36..1a6a640 100644
--- a/drivers/char/misc.c
+++ b/drivers/char/misc.c
@@ -198,7 +198,7 @@ int misc_register(struct miscdevice * misc)
err = -EBUSY;
goto out;
}
- misc->minor = DYNAMIC_MINORS - i - 1;
+ misc->minor = DYNAMIC_MINORS - i - 1 + DYNAMIC_MINOR_START;
set_bit(i, misc_minors);
} else {
struct miscdevice *c;
@@ -218,8 +218,7 @@ int misc_register(struct miscdevice * misc)
misc, misc->groups, "%s", misc->name);
if (IS_ERR(misc->this_device)) {
if (is_dynamic) {
- int i = DYNAMIC_MINORS - misc->minor - 1;
+ int i = DYNAMIC_MINORS - misc->minor - 1 + DYNAMIC_MINOR_START;
if (i < DYNAMIC_MINORS && i >= 0)
clear_bit(i, misc_minors);
misc->minor = MISC_DYNAMIC_MINOR;
diff --git a/include/linux/miscdevice.h b/include/linux/miscdevice.h
index 81f6e42..7aa931e 100644
--- a/include/linux/miscdevice.h
+++ b/include/linux/miscdevice.h
@@ -19,6 +19,7 @@
#define APOLLO_MOUSE_MINOR 7 /* unused */
#define PC110PAD_MINOR 9 /* unused */
/*#define ADB_MOUSE_MINOR 10 FIXME OBSOLETE */
+#define DYNAMIC_MINOR_START 11
#define WATCHDOG_MINOR 130 /* Watchdog timer */
#define TEMP_MINOR 131 /* Temperature Sensor */
#define RTC_MINOR 135
--
1.7.9.5
Nitin Gupta
Logix Cyber Park Plot No. C 28-29, Tower D - Ground to 10th Floor, Tower C - 8th to 10th Floor, Sector 62 Noida(U.P.) 201301 INDIA
ÿôèº{.nÇ+·®+%Ëÿ±éݶ\x17¥wÿº{.nÇ+·¥{±þG«éÿ{ayº\x1dÊÚë,j\a¢f£¢·hïêÿêçz_è®\x03(éÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?¨èÚ&£ø§~á¶iOæ¬z·vØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?I¥
next reply other threads:[~2015-12-09 12:51 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-09 12:51 Nitin Gupta [this message]
2015-12-09 13:35 ` [PATCH] char:misc minor is overflowing One Thousand Gnomes
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=1925385281.482851449665491986.JavaMail.weblogic@epmlwas08d \
--to=nitin.gupta@samsung.com \
--cc=arnd@arndb.de \
--cc=gaurav.k6@samsung.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=p.shailesh@samsung.com \
--cc=rajat.suri@samsung.com \
--cc=shiv.jnumca08@gmail.com \
--cc=shivnandan.k@samsung.com \
--cc=vidushi.koul@samsung.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