From: Rui Miguel Silva <rmfrfs@gmail.com>
To: Sakari Ailus <sakari.ailus@iki.fi>
Cc: Hans Verkuil <hverkuil@xs4all.nl>,
Sakari Ailus <sakari.ailus@linux.intel.com>,
linux-media@vger.kernel.org, linux-leds@vger.kernel.org,
jacek.anaszewski@gmail.com, laurent.pinchart@ideasonboard.com,
Johan Hovold <johan@kernel.org>, Alex Elder <elder@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
greybus-dev@lists.linaro.org, devel@driverdev.osuosl.org,
viresh.kumar@linaro.org
Subject: Re: [PATCH v2 1/3] staging: greybus: light: fix memory leak in v4l2 register
Date: Thu, 10 Aug 2017 15:43:35 +0100 [thread overview]
Message-ID: <20170810144335.GA22689@arch-late.localdomain> (raw)
In-Reply-To: <20170810135650.d62h2g4bxqkndiaa@valkosipuli.retiisi.org.uk>
Hi,
On Thu, Aug 10, 2017 at 04:56:50PM +0300, Sakari Ailus wrote:
> Hi Hans,
>
> On Thu, Aug 10, 2017 at 03:02:46PM +0200, Hans Verkuil wrote:
> > > @@ -534,25 +534,20 @@ static int gb_lights_light_v4l2_register(struct gb_light *light)
> > > {
> > > struct gb_connection *connection = get_conn_from_light(light);
> > > struct device *dev = &connection->bundle->dev;
> > > - struct v4l2_flash_config *sd_cfg;
> > > + struct v4l2_flash_config sd_cfg = { {0} };
> >
> > Just use '= {};'
>
> This is GCC specific whereas { {0} } is standard C. The latter is thus
> obviously better IMO.
My thought exactly. Let keep it this way, please.
>
> >
> > > struct led_classdev_flash *fled;
> > > struct led_classdev *iled = NULL;
> > > struct gb_channel *channel_torch, *channel_ind, *channel_flash;
> > > - int ret = 0;
> > > -
> > > - sd_cfg = kcalloc(1, sizeof(*sd_cfg), GFP_KERNEL);
> > > - if (!sd_cfg)
> > > - return -ENOMEM;
> > >
> > > channel_torch = get_channel_from_mode(light, GB_CHANNEL_MODE_TORCH);
> > > if (channel_torch)
> > > __gb_lights_channel_v4l2_config(&channel_torch->intensity_uA,
> > > - &sd_cfg->torch_intensity);
> > > + &sd_cfg.torch_intensity);
> > >
> > > channel_ind = get_channel_from_mode(light, GB_CHANNEL_MODE_INDICATOR);
> > > if (channel_ind) {
> > > __gb_lights_channel_v4l2_config(&channel_ind->intensity_uA,
> > > - &sd_cfg->indicator_intensity);
> > > + &sd_cfg.indicator_intensity);
> > > iled = &channel_ind->fled.led_cdev;
> > > }
> > >
> > > @@ -561,27 +556,21 @@ static int gb_lights_light_v4l2_register(struct gb_light *light)
> > >
> > > fled = &channel_flash->fled;
> > >
> > > - snprintf(sd_cfg->dev_name, sizeof(sd_cfg->dev_name), "%s", light->name);
> > > + snprintf(sd_cfg.dev_name, sizeof(sd_cfg.dev_name), "%s", light->name);
> > >
> > > /* Set the possible values to faults, in our case all faults */
> > > - sd_cfg->flash_faults = LED_FAULT_OVER_VOLTAGE | LED_FAULT_TIMEOUT |
> > > + sd_cfg.flash_faults = LED_FAULT_OVER_VOLTAGE | LED_FAULT_TIMEOUT |
> > > LED_FAULT_OVER_TEMPERATURE | LED_FAULT_SHORT_CIRCUIT |
> > > LED_FAULT_OVER_CURRENT | LED_FAULT_INDICATOR |
> > > LED_FAULT_UNDER_VOLTAGE | LED_FAULT_INPUT_VOLTAGE |
> > > LED_FAULT_LED_OVER_TEMPERATURE;
> > >
> > > light->v4l2_flash = v4l2_flash_init(dev, NULL, fled, iled,
> > > - &v4l2_flash_ops, sd_cfg);
> > > - if (IS_ERR_OR_NULL(light->v4l2_flash)) {
> > > - ret = PTR_ERR(light->v4l2_flash);
> > > - goto out_free;
> > > - }
> > > + &v4l2_flash_ops, &sd_cfg);
> > > + if (IS_ERR_OR_NULL(light->v4l2_flash))
> >
> > Just IS_ERR since v4l2_flash_init() never returns NULL.
>
> Will fix.
Thanks for that Sakari.
---
Cheers,
Rui
>
> >
> > > + return PTR_ERR(light->v4l2_flash);
> > >
> > > - return ret;
> > > -
> > > -out_free:
> > > - kfree(sd_cfg);
> > > - return ret;
> > > + return 0;
> > > }
> > >
> > > static void gb_lights_light_v4l2_unregister(struct gb_light *light)
> > >
> >
> > After those two changes:
> >
> > Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
>
> --
> Regards,
>
> Sakari Ailus
> e-mail: sakari.ailus@iki.fi XMPP: sailus@retiisi.org.uk
next prev parent reply other threads:[~2017-08-10 14:43 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-09 11:15 [PATCH v2 0/3] Create sub-device per LED Sakari Ailus
2017-08-09 11:15 ` [PATCH v2 1/3] staging: greybus: light: fix memory leak in v4l2 register Sakari Ailus
2017-08-09 13:20 ` Rui Miguel Silva
2017-08-09 15:36 ` Sakari Ailus
2017-08-09 16:06 ` Rui Miguel Silva
2017-08-10 13:02 ` Hans Verkuil
2017-08-10 13:09 ` Hans Verkuil
2017-08-10 13:56 ` Sakari Ailus
2017-08-10 14:43 ` Rui Miguel Silva [this message]
2017-08-09 11:15 ` [PATCH v2 2/3] v4l2-flash-led-class: Create separate sub-devices for indicators Sakari Ailus
2017-08-09 16:09 ` Rui Miguel Silva
2017-08-10 13:18 ` Hans Verkuil
2017-08-09 11:15 ` [PATCH v2 3/3] v4l2-flash-led-class: Document v4l2_flash_init() references Sakari Ailus
2017-08-10 13:16 ` Hans Verkuil
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170810144335.GA22689@arch-late.localdomain \
--to=rmfrfs@gmail.com \
--cc=devel@driverdev.osuosl.org \
--cc=elder@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=greybus-dev@lists.linaro.org \
--cc=hverkuil@xs4all.nl \
--cc=jacek.anaszewski@gmail.com \
--cc=johan@kernel.org \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-leds@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=sakari.ailus@iki.fi \
--cc=sakari.ailus@linux.intel.com \
--cc=viresh.kumar@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).