* [PATCH] uio: fix allocating minor id for uio device
@ 2011-03-27 7:22 zhdxzx
0 siblings, 0 replies; 6+ messages in thread
From: zhdxzx @ 2011-03-27 7:22 UTC (permalink / raw)
To: linux-kernel
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=GBK, Size: 859 bytes --]
The number of uio devices that could be used should be less than UIO_MAX_DEVICES by design,
and this work guards any cases in which id more than UIO_MAX_DEVICES is utilized.
Signed-off-by: Hillf Danton <dhillf@gmail.com>
---
--- a/drivers/uio/uio.c 2011-01-05 08:50:20.000000000 +0800
+++ b/drivers/uio/uio.c 2011-03-27 15:05:26.000000000 +0800
@@ -381,7 +381,13 @@ static int uio_get_minor(struct uio_devi
retval = -ENOMEM;
goto exit;
}
- idev->minor = id & MAX_ID_MASK;
+ if (id < UIO_MAX_DEVICES)
+ idev->minor = id;
+ else {
+ printk(KERN_ERR "uio: too many uio devices\n");
+ retval = -EINVAL;
+ idr_remove(&uio_idr, id);
+ }
exit:
mutex_unlock(&minor_lock);
return retval;
ÿôèº{.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¥
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] uio: fix allocating minor id for uio device
@ 2011-03-27 8:00 Hillf Danton
2011-03-28 21:45 ` Hans J. Koch
0 siblings, 1 reply; 6+ messages in thread
From: Hillf Danton @ 2011-03-27 8:00 UTC (permalink / raw)
To: linux-kernel
The number of uio devices that could be used should be less than
UIO_MAX_DEVICES by design,
and this work guards any cases in which id more than UIO_MAX_DEVICES
is utilized.
Signed-off-by: Hillf Danton <dhillf@gmail.com>
---
--- a/drivers/uio/uio.c 2011-01-05 08:50:20.000000000 +0800
+++ b/drivers/uio/uio.c 2011-03-27 15:05:26.000000000 +0800
@@ -381,7 +381,13 @@ static int uio_get_minor(struct uio_devi
retval = -ENOMEM;
goto exit;
}
- idev->minor = id & MAX_ID_MASK;
+ if (id < UIO_MAX_DEVICES)
+ idev->minor = id;
+ else {
+ printk(KERN_ERR "uio: too many uio devices\n");
+ retval = -EINVAL;
+ idr_remove(&uio_idr, id);
+ }
exit:
mutex_unlock(&minor_lock);
return retval;
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] uio: fix allocating minor id for uio device
2011-03-27 8:00 [PATCH] uio: fix allocating minor id for uio device Hillf Danton
@ 2011-03-28 21:45 ` Hans J. Koch
2011-03-29 8:40 ` Wolfram Sang
2011-03-31 12:38 ` Hillf Danton
0 siblings, 2 replies; 6+ messages in thread
From: Hans J. Koch @ 2011-03-28 21:45 UTC (permalink / raw)
To: Hillf Danton; +Cc: Greg KH, LKML
On Sun, Mar 27, 2011 at 04:00:39PM +0800, Hillf Danton wrote:
(Added Greg KH to Cc:)
> The number of uio devices that could be used should be less than
> UIO_MAX_DEVICES by design,
> and this work guards any cases in which id more than UIO_MAX_DEVICES
> is utilized.
>
> Signed-off-by: Hillf Danton <dhillf@gmail.com>
> ---
>
> --- a/drivers/uio/uio.c 2011-01-05 08:50:20.000000000 +0800
> +++ b/drivers/uio/uio.c 2011-03-27 15:05:26.000000000 +0800
> @@ -381,7 +381,13 @@ static int uio_get_minor(struct uio_devi
> retval = -ENOMEM;
> goto exit;
> }
> - idev->minor = id & MAX_ID_MASK;
> + if (id < UIO_MAX_DEVICES)
> + idev->minor = id;
> + else {
> + printk(KERN_ERR "uio: too many uio devices\n");
No printk(), please. Use dev_err().
Otherwise, it looks good to me.
Thanks,
Hans
> + retval = -EINVAL;
> + idr_remove(&uio_idr, id);
> + }
> exit:
> mutex_unlock(&minor_lock);
> return retval;
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] uio: fix allocating minor id for uio device
2011-03-28 21:45 ` Hans J. Koch
@ 2011-03-29 8:40 ` Wolfram Sang
2011-03-31 12:38 ` Hillf Danton
1 sibling, 0 replies; 6+ messages in thread
From: Wolfram Sang @ 2011-03-29 8:40 UTC (permalink / raw)
To: Hans J. Koch; +Cc: Hillf Danton, Greg KH, LKML
[-- Attachment #1: Type: text/plain, Size: 404 bytes --]
> > - idev->minor = id & MAX_ID_MASK;
> > + if (id < UIO_MAX_DEVICES)
> > + idev->minor = id;
> > + else {
As it needs respinning anyway: If the else-block has braces, it is
recommended for the if-block, too
Regards,
Wolfram
--
Pengutronix e.K. | Wolfram Sang |
Industrial Linux Solutions | http://www.pengutronix.de/ |
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] uio: fix allocating minor id for uio device
2011-03-28 21:45 ` Hans J. Koch
2011-03-29 8:40 ` Wolfram Sang
@ 2011-03-31 12:38 ` Hillf Danton
2011-03-31 17:55 ` Hans J. Koch
1 sibling, 1 reply; 6+ messages in thread
From: Hillf Danton @ 2011-03-31 12:38 UTC (permalink / raw)
To: Hans J. Koch; +Cc: Greg KH, LKML
The number of uio devices that could be used should be less than
UIO_MAX_DEVICES by design, and this work guards any cases in which id
more than UIO_MAX_DEVICES is utilized.
Signed-off-by: Hillf Danton <dhillf@gmail.com>
---
--- a/drivers/uio/uio.c 2011-01-05 08:50:20.000000000 +0800
+++ b/drivers/uio/uio.c 2011-03-31 20:43:44.000000000 +0800
@@ -381,7 +381,13 @@ static int uio_get_minor(struct uio_devi
retval = -ENOMEM;
goto exit;
}
- idev->minor = id & MAX_ID_MASK;
+ if (id < UIO_MAX_DEVICES) {
+ idev->minor = id;
+ } else {
+ dev_err(idev->dev, "too many uio devices\n");
+ retval = -EINVAL;
+ idr_remove(&uio_idr, id);
+ }
exit:
mutex_unlock(&minor_lock);
return retval;
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] uio: fix allocating minor id for uio device
2011-03-31 12:38 ` Hillf Danton
@ 2011-03-31 17:55 ` Hans J. Koch
0 siblings, 0 replies; 6+ messages in thread
From: Hans J. Koch @ 2011-03-31 17:55 UTC (permalink / raw)
To: Hillf Danton; +Cc: Hans J. Koch, Greg KH, LKML
On Thu, Mar 31, 2011 at 08:38:47PM +0800, Hillf Danton wrote:
> The number of uio devices that could be used should be less than
> UIO_MAX_DEVICES by design, and this work guards any cases in which id
> more than UIO_MAX_DEVICES is utilized.
Looks good.
Thanks for your work,
Hans
>
> Signed-off-by: Hillf Danton <dhillf@gmail.com>
Signed-off-by: Hans J. Koch <hjk@hansjkoch.de>
> ---
>
> --- a/drivers/uio/uio.c 2011-01-05 08:50:20.000000000 +0800
> +++ b/drivers/uio/uio.c 2011-03-31 20:43:44.000000000 +0800
> @@ -381,7 +381,13 @@ static int uio_get_minor(struct uio_devi
> retval = -ENOMEM;
> goto exit;
> }
> - idev->minor = id & MAX_ID_MASK;
> + if (id < UIO_MAX_DEVICES) {
> + idev->minor = id;
> + } else {
> + dev_err(idev->dev, "too many uio devices\n");
> + retval = -EINVAL;
> + idr_remove(&uio_idr, id);
> + }
> exit:
> mutex_unlock(&minor_lock);
> return retval;
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-03-31 17:55 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-27 8:00 [PATCH] uio: fix allocating minor id for uio device Hillf Danton
2011-03-28 21:45 ` Hans J. Koch
2011-03-29 8:40 ` Wolfram Sang
2011-03-31 12:38 ` Hillf Danton
2011-03-31 17:55 ` Hans J. Koch
-- strict thread matches above, loose matches on Subject: below --
2011-03-27 7:22 zhdxzx
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox