[bug report] media: atomisp: place all gpio parsing together

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Mauro Carvalho Chehab,

This is a semi-automatic email about new static checker warnings.

The patch 79317baaaea2: "media: atomisp: place all gpio parsing 
together" from Jun 21, 2020, leads to the following Smatch complaint:

    drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c:830 gmin_v1p8_ctrl()
    warn: variable dereferenced before check 'gs' (see line 820)

drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
   814  static int gmin_v1p8_ctrl(struct v4l2_subdev *subdev, int on)
   815  {
   816          struct gmin_subdev *gs = find_gmin_subdev(subdev);
   817          int ret;
   818          int value;
   819	
   820		if (gs->v1p8_gpio >= 0) {
                    ^^
New dereference.

   821			pr_info("atomisp_gmin_platform: 1.8v power on GPIO %d\n",
   822				gs->v1p8_gpio);
   823			ret = gpio_request(gs->v1p8_gpio, "camera_v1p8_en");
   824			if (!ret)
   825				ret = gpio_direction_output(gs->v1p8_gpio, 0);
   826			if (ret)
   827				pr_err("V1P8 GPIO initialization failed\n");
   828		}
   829	
   830		if (!gs || gs->v1p8_on == on)
                     ^^
Too late.

   831			return 0;
   832		gs->v1p8_on = on;
   833  
   834          if (gs->v1p8_gpio >= 0)
   835                  gpio_set_value(gs->v1p8_gpio, on);

Could we combine this with the first "if (gs->v1p8_gpio >= 0) {"
condition?  This code is looking pretty subtle so maybe not.

   836  
   837          if (gs->v1p8_reg) {
   838                  regulator_set_voltage(gs->v1p8_reg, 1800000, 1800000);
   839                  if (on)
   840                          return regulator_enable(gs->v1p8_reg);
   841                  else
   842                          return regulator_disable(gs->v1p8_reg);
   843          }
   844  

regards,
dan carpenter



[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux