diff mbox

cnic: ensure ulp_type is not negative

Message ID 4AEF0E98.5050304@gmail.com
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

roel kluin Nov. 2, 2009, 4:53 p.m. UTC
`ulp_type' is signed, make sure it is not negative
when we read the array element.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
 drivers/net/cnic.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Michael Chan Nov. 2, 2009, 5:56 p.m. UTC | #1
On Mon, 2009-11-02 at 08:53 -0800, Roel Kluin wrote:
> `ulp_type' is signed, make sure it is not negative
> when we read the array element.
> 
> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>

Looks good to me.  Thanks.
Acked-by: Michael Chan <mchan@broadcom.com>

> ---
>  drivers/net/cnic.c |    8 ++++----
>  1 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/cnic.c b/drivers/net/cnic.c
> index 3bf1b04..f384b0a 100644
> --- a/drivers/net/cnic.c
> +++ b/drivers/net/cnic.c
> @@ -347,7 +347,7 @@ int cnic_register_driver(int ulp_type, struct cnic_ulp_ops *ulp_ops)
>  {
>  	struct cnic_dev *dev;
>  
> -	if (ulp_type >= MAX_CNIC_ULP_TYPE) {
> +	if (ulp_type < 0 || ulp_type >= MAX_CNIC_ULP_TYPE) {
>  		printk(KERN_ERR PFX "cnic_register_driver: Bad type %d\n",
>  		       ulp_type);
>  		return -EINVAL;
> @@ -393,7 +393,7 @@ int cnic_unregister_driver(int ulp_type)
>  	struct cnic_ulp_ops *ulp_ops;
>  	int i = 0;
>  
> -	if (ulp_type >= MAX_CNIC_ULP_TYPE) {
> +	if (ulp_type < 0 || ulp_type >= MAX_CNIC_ULP_TYPE) {
>  		printk(KERN_ERR PFX "cnic_unregister_driver: Bad type %d\n",
>  		       ulp_type);
>  		return -EINVAL;
> @@ -449,7 +449,7 @@ static int cnic_register_device(struct cnic_dev *dev, int ulp_type,
>  	struct cnic_local *cp = dev->cnic_priv;
>  	struct cnic_ulp_ops *ulp_ops;
>  
> -	if (ulp_type >= MAX_CNIC_ULP_TYPE) {
> +	if (ulp_type < 0 || ulp_type >= MAX_CNIC_ULP_TYPE) {
>  		printk(KERN_ERR PFX "cnic_register_device: Bad type %d\n",
>  		       ulp_type);
>  		return -EINVAL;
> @@ -490,7 +490,7 @@ static int cnic_unregister_device(struct cnic_dev *dev, int ulp_type)
>  	struct cnic_local *cp = dev->cnic_priv;
>  	int i = 0;
>  
> -	if (ulp_type >= MAX_CNIC_ULP_TYPE) {
> +	if (ulp_type < 0 || ulp_type >= MAX_CNIC_ULP_TYPE) {
>  		printk(KERN_ERR PFX "cnic_unregister_device: Bad type %d\n",
>  		       ulp_type);
>  		return -EINVAL;
> 


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller Nov. 4, 2009, 1:07 p.m. UTC | #2
From: "Michael Chan" <mchan@broadcom.com>
Date: Mon, 2 Nov 2009 09:56:59 -0800

> 
> On Mon, 2009-11-02 at 08:53 -0800, Roel Kluin wrote:
>> `ulp_type' is signed, make sure it is not negative
>> when we read the array element.
>> 
>> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
> 
> Looks good to me.  Thanks.
> Acked-by: Michael Chan <mchan@broadcom.com>

Applied to net-next-2.6
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/net/cnic.c b/drivers/net/cnic.c
index 3bf1b04..f384b0a 100644
--- a/drivers/net/cnic.c
+++ b/drivers/net/cnic.c
@@ -347,7 +347,7 @@  int cnic_register_driver(int ulp_type, struct cnic_ulp_ops *ulp_ops)
 {
 	struct cnic_dev *dev;
 
-	if (ulp_type >= MAX_CNIC_ULP_TYPE) {
+	if (ulp_type < 0 || ulp_type >= MAX_CNIC_ULP_TYPE) {
 		printk(KERN_ERR PFX "cnic_register_driver: Bad type %d\n",
 		       ulp_type);
 		return -EINVAL;
@@ -393,7 +393,7 @@  int cnic_unregister_driver(int ulp_type)
 	struct cnic_ulp_ops *ulp_ops;
 	int i = 0;
 
-	if (ulp_type >= MAX_CNIC_ULP_TYPE) {
+	if (ulp_type < 0 || ulp_type >= MAX_CNIC_ULP_TYPE) {
 		printk(KERN_ERR PFX "cnic_unregister_driver: Bad type %d\n",
 		       ulp_type);
 		return -EINVAL;
@@ -449,7 +449,7 @@  static int cnic_register_device(struct cnic_dev *dev, int ulp_type,
 	struct cnic_local *cp = dev->cnic_priv;
 	struct cnic_ulp_ops *ulp_ops;
 
-	if (ulp_type >= MAX_CNIC_ULP_TYPE) {
+	if (ulp_type < 0 || ulp_type >= MAX_CNIC_ULP_TYPE) {
 		printk(KERN_ERR PFX "cnic_register_device: Bad type %d\n",
 		       ulp_type);
 		return -EINVAL;
@@ -490,7 +490,7 @@  static int cnic_unregister_device(struct cnic_dev *dev, int ulp_type)
 	struct cnic_local *cp = dev->cnic_priv;
 	int i = 0;
 
-	if (ulp_type >= MAX_CNIC_ULP_TYPE) {
+	if (ulp_type < 0 || ulp_type >= MAX_CNIC_ULP_TYPE) {
 		printk(KERN_ERR PFX "cnic_unregister_device: Bad type %d\n",
 		       ulp_type);
 		return -EINVAL;