All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lee Jones <lee.jones@linaro.org>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Samuel Ortiz <sameo@linux.intel.com>,
	Octavian Purdila <octavian.purdila@intel.com>,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [patch 2/2 -next] mfd: dln2: a couple endian fixes
Date: Tue, 18 Nov 2014 15:53:57 +0000	[thread overview]
Message-ID: <20141118155357.GC13959@x1> (raw)
In-Reply-To: <20141113103607.GB17038@mwanda>

On Thu, 13 Nov 2014, Dan Carpenter wrote:

> Sparse catches a couple endian bugs.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> Not tested.

Applied until someone screams.

> diff --git a/drivers/mfd/dln2.c b/drivers/mfd/dln2.c
> index 3101e5e..babf7b6 100644
> --- a/drivers/mfd/dln2.c
> +++ b/drivers/mfd/dln2.c
> @@ -437,6 +437,7 @@ static int _dln2_transfer(struct dln2_dev *dln2, u16 handle, u16 cmd,
>  	struct device *dev = &dln2->interface->dev;
>  	const unsigned long timeout = DLN2_USB_TIMEOUT * HZ / 1000;
>  	struct dln2_mod_rx_slots *rxs = &dln2->mod_rx_slots[handle];
> +	int size;
>  
>  	spin_lock(&dln2->disconnect_lock);
>  	if (!dln2->disconnect)
> @@ -476,8 +477,9 @@ static int _dln2_transfer(struct dln2_dev *dln2, u16 handle, u16 cmd,
>  
>  	/* if we got here we know that the response header has been checked */
>  	rsp = rxc->urb->transfer_buffer;
> +	size = le16_to_cpu(rsp->hdr.size);
>  
> -	if (rsp->hdr.size < sizeof(*rsp)) {
> +	if (size < sizeof(*rsp)) {
>  		ret = -EPROTO;
>  		goto out_free_rx_slot;
>  	}
> @@ -494,8 +496,8 @@ static int _dln2_transfer(struct dln2_dev *dln2, u16 handle, u16 cmd,
>  		goto out_free_rx_slot;
>  	}
>  
> -	if (*ibuf_len > rsp->hdr.size - sizeof(*rsp))
> -		*ibuf_len = rsp->hdr.size - sizeof(*rsp);
> +	if (*ibuf_len > size - sizeof(*rsp))
> +		*ibuf_len = size - sizeof(*rsp);
>  
>  	memcpy(ibuf, rsp + 1, *ibuf_len);
>  

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

WARNING: multiple messages have this Message-ID (diff)
From: Lee Jones <lee.jones@linaro.org>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Samuel Ortiz <sameo@linux.intel.com>,
	Octavian Purdila <octavian.purdila@intel.com>,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [patch 2/2 -next] mfd: dln2: a couple endian fixes
Date: Tue, 18 Nov 2014 15:53:57 +0000	[thread overview]
Message-ID: <20141118155357.GC13959@x1> (raw)
In-Reply-To: <20141113103607.GB17038@mwanda>

On Thu, 13 Nov 2014, Dan Carpenter wrote:

> Sparse catches a couple endian bugs.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> Not tested.

Applied until someone screams.

> diff --git a/drivers/mfd/dln2.c b/drivers/mfd/dln2.c
> index 3101e5e..babf7b6 100644
> --- a/drivers/mfd/dln2.c
> +++ b/drivers/mfd/dln2.c
> @@ -437,6 +437,7 @@ static int _dln2_transfer(struct dln2_dev *dln2, u16 handle, u16 cmd,
>  	struct device *dev = &dln2->interface->dev;
>  	const unsigned long timeout = DLN2_USB_TIMEOUT * HZ / 1000;
>  	struct dln2_mod_rx_slots *rxs = &dln2->mod_rx_slots[handle];
> +	int size;
>  
>  	spin_lock(&dln2->disconnect_lock);
>  	if (!dln2->disconnect)
> @@ -476,8 +477,9 @@ static int _dln2_transfer(struct dln2_dev *dln2, u16 handle, u16 cmd,
>  
>  	/* if we got here we know that the response header has been checked */
>  	rsp = rxc->urb->transfer_buffer;
> +	size = le16_to_cpu(rsp->hdr.size);
>  
> -	if (rsp->hdr.size < sizeof(*rsp)) {
> +	if (size < sizeof(*rsp)) {
>  		ret = -EPROTO;
>  		goto out_free_rx_slot;
>  	}
> @@ -494,8 +496,8 @@ static int _dln2_transfer(struct dln2_dev *dln2, u16 handle, u16 cmd,
>  		goto out_free_rx_slot;
>  	}
>  
> -	if (*ibuf_len > rsp->hdr.size - sizeof(*rsp))
> -		*ibuf_len = rsp->hdr.size - sizeof(*rsp);
> +	if (*ibuf_len > size - sizeof(*rsp))
> +		*ibuf_len = size - sizeof(*rsp);
>  
>  	memcpy(ibuf, rsp + 1, *ibuf_len);
>  

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

  parent reply	other threads:[~2014-11-18 15:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-13 10:36 [patch 2/2 -next] mfd: dln2: a couple endian fixes Dan Carpenter
2014-11-13 10:36 ` Dan Carpenter
2014-11-13 11:18 ` Octavian Purdila
2014-11-13 11:18   ` Octavian Purdila
2014-11-18 15:53 ` Lee Jones [this message]
2014-11-18 15:53   ` Lee Jones

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=20141118155357.GC13959@x1 \
    --to=lee.jones@linaro.org \
    --cc=dan.carpenter@oracle.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=octavian.purdila@intel.com \
    --cc=sameo@linux.intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.