Re: [PATCH] drivers: scsi: ufs: Fix possible null derefrence

From: Gilad Broner
Date: Tue Mar 10 2015 - 06:28:52 EST


> Check for null before being dereferenced to avoid a invalid null
> dereference.
>
> Found using Coccinelle.
>
> Signed-off-by: Tapasweni Pathak <tapaswenipathak@xxxxxxxxx>
> Acked-by: Julia Lawall <julia.lawall@xxxxxxx>
> ---
> drivers/scsi/ufs/ufshcd.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
> index 5d60a86..c54e64f 100644
> --- a/drivers/scsi/ufs/ufshcd.c
> +++ b/drivers/scsi/ufs/ufshcd.c
> @@ -4268,12 +4268,15 @@ static int ufshcd_config_vreg(struct device *dev,
> struct ufs_vreg *vreg, bool on)
> {
> int ret = 0;
> - struct regulator *reg = vreg->reg;
> - const char *name = vreg->name;
> + struct regulator *reg;
> + const char *name;
> int min_uV, uA_load;
>
> BUG_ON(!vreg);


Please add to the patch fix for another instance of this in
ufshcd_config_vreg_load():

static int ufshcd_config_vreg_load(struct device *dev,
struct ufs_vreg *vreg, int ua)
{
int ret = 0;
struct regulator *reg = vreg->reg;
const char *name = vreg->name;

BUG_ON(!vreg);


Gilad.

--
Qualcomm Israel, on behalf of Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/