[ofa-general] [PATCH] EHCA: Enforce a positive guid_entry index
Alexander Schmidt
alexs at linux.vnet.ibm.com
Tue Jun 16 00:35:57 PDT 2009
Hi Roel,
On Mon, 15 Jun 2009 20:04:08 +0200
Roel Kluin <roel.kluin at gmail.com> wrote:
> This prevents the memcpy of a guid_entries element using a negative index.
>
> Signed-off-by: Roel Kluin <roel.kluin at gmail.com>
> ---
> drivers/infiniband/hw/ehca/ehca_hca.c | 2 +-
> drivers/infiniband/hw/ehca/ehca_iverbs.h | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/infiniband/hw/ehca/ehca_hca.c b/drivers/infiniband/hw/ehca/ehca_hca.c
> index 9209c53..1175ee1 100644
> --- a/drivers/infiniband/hw/ehca/ehca_hca.c
> +++ b/drivers/infiniband/hw/ehca/ehca_hca.c
> @@ -311,7 +311,7 @@ query_pkey1:
> }
>
> int ehca_query_gid(struct ib_device *ibdev, u8 port,
> - int index, union ib_gid *gid)
> + unsigned index, union ib_gid *gid)
> {
> int ret = 0;
> u64 h_ret;
> diff --git a/drivers/infiniband/hw/ehca/ehca_iverbs.h b/drivers/infiniband/hw/ehca/ehca_iverbs.h
> index 8f7f282..05a83bb 100644
> --- a/drivers/infiniband/hw/ehca/ehca_iverbs.h
> +++ b/drivers/infiniband/hw/ehca/ehca_iverbs.h
> @@ -54,7 +54,7 @@ int ehca_query_sma_attr(struct ehca_shca *shca, u8 port,
>
> int ehca_query_pkey(struct ib_device *ibdev, u8 port, u16 index, u16 * pkey);
>
> -int ehca_query_gid(struct ib_device *ibdev, u8 port, int index,
> +int ehca_query_gid(struct ib_device *ibdev, u8 port, unsigned index,
> union ib_gid *gid);
>
> int ehca_modify_port(struct ib_device *ibdev, u8 port, int port_modify_mask,
Thank you for checking this code. I think a better solution for this would be to
change the index parameter of ehca_query_gid() from int to u8. Both functions
that call ehca_query_gid() pass an u8 and this way you could also remove the
if (index > 255) {
ehca_err(&shca->ib_device, "Invalid index: %x.", index);
return -EINVAL;
}
check from ehca_query_gid().
If you could send an updated patch, I would be happy to take a look again
and ack it.
Regards,
Alex
More information about the general
mailing list