On Thu, 2017-09-14 at 14:16 +0800, shuw...@redhat.com wrote:
> diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c 
> b/drivers/scsi/megaraid/megaraid_sas_fusion.c
> index 11bd2e698b84..621299edd8de 100644
> --- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
> +++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
> @@ -48,6 +48,7 @@
>  #include <linux/mutex.h>
>  #include <linux/poll.h>
>  #include <linux/vmalloc.h>
> +#include <linux/kmemleak.h>
>  
>  #include <scsi/scsi.h>
>  #include <scsi/scsi_cmnd.h>
> @@ -4512,7 +4513,9 @@ megasas_alloc_fusion_context(struct megasas_instance 
> *instance)
>                       dev_err(&instance->pdev->dev, "Failed from %s %d\n", 
> __func__, __LINE__);
>                       return -ENOMEM;
>               }
> -     }
> +     } else
> +             kmemleak_alloc(instance->ctrl_context,
> +                     sizeof(struct fusion_context), 1, GFP_KERNEL);
>  
>       fusion = instance->ctrl_context;

Thank you for having tracked this down and for having shared this patch. But
please keep braces balanced to keep checkpatch happy and please also consider
adding a comment similar to the following above the kmemleak_alloc() call:

/* Allow kmemleak to scan these pages as they contain pointers to additional 
allocations. */

> @@ -4548,9 +4551,11 @@ megasas_free_fusion_context(struct megasas_instance 
> *instance)
>  
>               if (is_vmalloc_addr(fusion))
>                       vfree(fusion);
> -             else
> +             else {
>                       free_pages((ulong)fusion,
>                               instance->ctrl_context_pages);
> +                     kmemleak_free(fusion);
> +             }
>       }

Please keep braces balanced in the above code too.

Thanks,

Bart.

Reply via email to