Hi Ira,

Good catch, thank you.
I applied it, but I changed the return value to be 0, because we do not
want to end the execution.
So the final patch is:

commit d89490a22f0b781a505311bfa53f0acca983e097
Author: Ishai Rabinovitz <[email protected]>
Date:   Sun Apr 12 11:54:56 2009 +0300

    Fix a bug when there is no target in the fabric
    
    Signed-off-by: Ira Weiny <[email protected]>
    Signed-off-by: Ishai Rabinovitz <[email protected]>

diff --git a/srp_daemon/srp_daemon.c b/srp_daemon/srp_daemon.c
index 5e1e198..14087bd 100644
--- a/srp_daemon/srp_daemon.c
+++ b/srp_daemon/srp_daemon.c
@@ -943,6 +943,13 @@ static int do_dm_port_list(struct resources *res)
 
        size = ib_get_attr_size(in_sa_mad->attr_offset);
 
+       if (!size) {
+               if (config->verbose) {
+                       printf("Query did not find any targets\n");
+               }
+               return 0;
+       }
+
        for (i = 0; (i + 1) * size <= len - MAD_RMPP_HDR_SIZE; ++i) {
                port_info = (void *) in_sa_mad->data + i * size;

Ishai
> -----Original Message-----
> From: Ira Weiny [mailto:[email protected]]
> Sent: Friday, April 10, 2009 3:02 AM
> To: Ishai Rabinovitz
> Cc: OpenFabrics; D. Marc Stearman
> Subject: [PATCH] When no DM ports are found return an error
> 
> I think I have found a bug in srp_daemon when running on a fabric with
> no SRP targets.
> 
> The patch below fixes the issue.  This is when running against OpenSM
> 3.2.5.  Without this fix the daemon goes into an endless loop looking
> for the node with lid 0!
> 
> Ira
> 
> 
> From: Ira Weiny <[email protected]>
> Date: Thu, 9 Apr 2009 16:41:58 -0700
> Subject: [PATCH] When no DM ports are found return an error.
> 
> 
> Signed-off-by: Ira Weiny <[email protected]>
> ---
>  srp_daemon/srp_daemon.c |    3 +++
>  1 files changed, 3 insertions(+), 0 deletions(-)
> 
> diff --git a/srp_daemon/srp_daemon.c b/srp_daemon/srp_daemon.c
> index 5e1e198..621678b 100644
> --- a/srp_daemon/srp_daemon.c
> +++ b/srp_daemon/srp_daemon.c
> @@ -943,6 +943,9 @@ static int do_dm_port_list(struct resources *res)
> 
>       size = ib_get_attr_size(in_sa_mad->attr_offset);
> 
> +     if (!size)
> +             return -1;
> +
>       for (i = 0; (i + 1) * size <= len - MAD_RMPP_HDR_SIZE; ++i) {
>               port_info = (void *) in_sa_mad->data + i * size;
> 
> --
> 1.5.4.5

_______________________________________________
general mailing list
[email protected]
http://lists.openfabrics.org/cgi-bin/mailman/listinfo/general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general

Reply via email to