linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Machek <pavel@ucw.cz>
To: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: linux-media@vger.kernel.org, linux-leds@vger.kernel.org,
	jacek.anaszewski@gmail.com, laurent.pinchart@ideasonboard.com
Subject: Re: [PATCH 1/2] staging: greybus: light: Don't leak memory for no gain
Date: Wed, 19 Jul 2017 13:59:35 +0200	[thread overview]
Message-ID: <20170719115934.GA23510@amd> (raw)
In-Reply-To: <20170718184107.10598-2-sakari.ailus@linux.intel.com>

[-- Attachment #1: Type: text/plain, Size: 1828 bytes --]

Hi!

> Memory for struct v4l2_flash_config is allocated in
> gb_lights_light_v4l2_register() for no gain and yet the allocated memory is
> leaked; the struct isn't used outside the function. Fix this.
> 
> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>


> diff --git a/drivers/staging/greybus/light.c b/drivers/staging/greybus/light.c
> index 129ceed39829..b25c117ec41a 100644
> --- a/drivers/staging/greybus/light.c
> +++ b/drivers/staging/greybus/light.c
> @@ -534,25 +534,21 @@ 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 };
>  	struct led_classdev_flash *fled;
>  	struct led_classdev *iled = NULL;
>  	struct gb_channel *channel_torch, *channel_ind, *channel_flash;
>  	int ret = 0;
....
>  	light->v4l2_flash = v4l2_flash_init(dev, NULL, fled, iled,
> -					    &v4l2_flash_ops, sd_cfg);
> +					    &v4l2_flash_ops, &sd_cfg);
>  	if (IS_ERR_OR_NULL(light->v4l2_flash)) {
>  		ret = PTR_ERR(light->v4l2_flash);
>  		goto out_free;

Acked-by: Pavel Machek <pavel@ucw.cz>

struct v4l2_flash *v4l2_flash_init(
        struct device *dev, struct fwnode_handle *fwn,
	       struct led_classdev_flash *fled_cdev,
	       	      struct led_classdev_flash *iled_cdev,
		      	     const struct v4l2_flash_ops *ops,
			     	   struct v4l2_flash_config *config)
				   
This function saves "ops" argument, but is careful to copy from
"config" argument. Perhaps that's worth a comment?

Thanks,
								Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

  reply	other threads:[~2017-07-19 11:59 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-18 18:41 [PATCH 0/2] Create sub-device per LED Sakari Ailus
2017-07-18 18:41 ` [PATCH 1/2] staging: greybus: light: Don't leak memory for no gain Sakari Ailus
2017-07-19 11:59   ` Pavel Machek [this message]
2017-07-19 22:40     ` [PATCH 1/1] v4l2-flash-led-class: Document v4l2_flash_init() references Sakari Ailus
2017-07-20  6:50       ` Pavel Machek
2017-07-25 12:30   ` [PATCH 1/2] staging: greybus: light: Don't leak memory for no gain Johan Hovold
2017-07-26 15:03     ` Rui Miguel Silva
2017-07-26 18:32       ` Pavel Machek
2017-07-27 13:59         ` Rui Miguel Silva
2017-07-18 18:41 ` [PATCH 2/2] v4l2-flash-led-class: Create separate sub-devices for indicators Sakari Ailus
2017-07-18 19:35   ` Jacek Anaszewski
2017-07-19 12:02   ` Pavel Machek
2017-07-19 22:42     ` Sakari Ailus
2017-08-07 22:45     ` Sakari Ailus

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=20170719115934.GA23510@amd \
    --to=pavel@ucw.cz \
    --cc=jacek.anaszewski@gmail.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-leds@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    /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).