linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] nfp: check idx is -ENOSPC before using it is an index
@ 2016-07-11 15:46 Colin King
  2016-07-11 15:52 ` NACK: " Colin Ian King
  2016-07-11 15:59 ` Samuel Ortiz
  0 siblings, 2 replies; 3+ messages in thread
From: Colin King @ 2016-07-11 15:46 UTC (permalink / raw)
  To: Jakub Kicinski, Lauro Ramos Venancio, Aloisio Almeida Jr,
	Samuel Ortiz, David S . Miller, Rolf Neugebauer,
	Christophe Ricard, Robert Dolca, oss-drivers, netdev,
	linux-wireless

From: Colin Ian King <colin.king@canonical.com>

idx can be returned as -ENOSPC, so we should check for this first
before using it as an index into nn->vxlan_usecnt[] to avoid an
out of bounds array offset read.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/net/ethernet/netronome/nfp/nfp_net_common.c | 2 +-
 drivers/nfc/fdp/fdp.c                               | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
index 1e74b91..88678c1 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
@@ -2578,7 +2578,7 @@ static void nfp_net_del_vxlan_port(struct net_device *netdev,
 		return;
 
 	idx = nfp_net_find_vxlan_idx(nn, ti->port);
-	if (!nn->vxlan_usecnt[idx] || idx == -ENOSPC)
+	if (idx == -ENOSPC || !nn->vxlan_usecnt[idx])
 		return;
 
 	if (!--nn->vxlan_usecnt[idx])
diff --git a/drivers/nfc/fdp/fdp.c b/drivers/nfc/fdp/fdp.c
index e44a7a2..d93d314 100644
--- a/drivers/nfc/fdp/fdp.c
+++ b/drivers/nfc/fdp/fdp.c
@@ -345,7 +345,7 @@ static void fdp_nci_release_firmware(struct nci_dev *ndev)
 
 	if (info->ram_patch) {
 		release_firmware(info->ram_patch);
-		info->otp_patch = NULL;
+		info->ram_patch = NULL;
 	}
 }
 
-- 
2.8.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* NACK: [PATCH] nfp: check idx is -ENOSPC before using it is an index
  2016-07-11 15:46 [PATCH] nfp: check idx is -ENOSPC before using it is an index Colin King
@ 2016-07-11 15:52 ` Colin Ian King
  2016-07-11 15:59 ` Samuel Ortiz
  1 sibling, 0 replies; 3+ messages in thread
From: Colin Ian King @ 2016-07-11 15:52 UTC (permalink / raw)
  To: Jakub Kicinski, Lauro Ramos Venancio, Aloisio Almeida Jr,
	Samuel Ortiz, David S . Miller, Rolf Neugebauer,
	Christophe Ricard, Robert Dolca, oss-drivers, netdev,
	linux-wireless

Ignore this, got some other fix included by mistake. Will resend.

On 11/07/16 16:46, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> idx can be returned as -ENOSPC, so we should check for this first
> before using it as an index into nn->vxlan_usecnt[] to avoid an
> out of bounds array offset read.
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/net/ethernet/netronome/nfp/nfp_net_common.c | 2 +-
>  drivers/nfc/fdp/fdp.c                               | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
> index 1e74b91..88678c1 100644
> --- a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
> +++ b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
> @@ -2578,7 +2578,7 @@ static void nfp_net_del_vxlan_port(struct net_device *netdev,
>  		return;
>  
>  	idx = nfp_net_find_vxlan_idx(nn, ti->port);
> -	if (!nn->vxlan_usecnt[idx] || idx == -ENOSPC)
> +	if (idx == -ENOSPC || !nn->vxlan_usecnt[idx])
>  		return;
>  
>  	if (!--nn->vxlan_usecnt[idx])
> diff --git a/drivers/nfc/fdp/fdp.c b/drivers/nfc/fdp/fdp.c
> index e44a7a2..d93d314 100644
> --- a/drivers/nfc/fdp/fdp.c
> +++ b/drivers/nfc/fdp/fdp.c
> @@ -345,7 +345,7 @@ static void fdp_nci_release_firmware(struct nci_dev *ndev)
>  
>  	if (info->ram_patch) {
>  		release_firmware(info->ram_patch);
> -		info->otp_patch = NULL;
> +		info->ram_patch = NULL;
>  	}
>  }
>  
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] nfp: check idx is -ENOSPC before using it is an index
  2016-07-11 15:46 [PATCH] nfp: check idx is -ENOSPC before using it is an index Colin King
  2016-07-11 15:52 ` NACK: " Colin Ian King
@ 2016-07-11 15:59 ` Samuel Ortiz
  1 sibling, 0 replies; 3+ messages in thread
From: Samuel Ortiz @ 2016-07-11 15:59 UTC (permalink / raw)
  To: Colin King
  Cc: Jakub Kicinski, Lauro Ramos Venancio, Aloisio Almeida Jr,
	David S . Miller, Rolf Neugebauer, Christophe Ricard,
	Robert Dolca, oss-drivers, netdev, linux-wireless

Hi Colin,

On Mon, Jul 11, 2016 at 04:46:57PM +0100, Colin King wrote:
> diff --git a/drivers/nfc/fdp/fdp.c b/drivers/nfc/fdp/fdp.c
> index e44a7a2..d93d314 100644
> --- a/drivers/nfc/fdp/fdp.c
> +++ b/drivers/nfc/fdp/fdp.c
> @@ -345,7 +345,7 @@ static void fdp_nci_release_firmware(struct nci_dev *ndev)
>  
>  	if (info->ram_patch) {
>  		release_firmware(info->ram_patch);
> -		info->otp_patch = NULL;
> +		info->ram_patch = NULL;
>  	}
>  }
This chunk is unrelated and also already applied to my nfc-next tree.

Cheers,
Samuel.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-07-11 16:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-11 15:46 [PATCH] nfp: check idx is -ENOSPC before using it is an index Colin King
2016-07-11 15:52 ` NACK: " Colin Ian King
2016-07-11 15:59 ` Samuel Ortiz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).