linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] media: go7007: fix a miss of snd_card_free
@ 2019-12-06 12:07 Chuhong Yuan
  2019-12-06 14:10 ` Markus Elfring
  0 siblings, 1 reply; 4+ messages in thread
From: Chuhong Yuan @ 2019-12-06 12:07 UTC (permalink / raw)
  Cc: Hans Verkuil, Mauro Carvalho Chehab, linux-media, linux-kernel,
	Chuhong Yuan

go7007_snd_init() misses a snd_card_free() in an error path.
Add the missed call to fix it.

Signed-off-by: Chuhong Yuan <hslester96@gmail.com>
---
 drivers/media/usb/go7007/snd-go7007.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/usb/go7007/snd-go7007.c b/drivers/media/usb/go7007/snd-go7007.c
index b05fa227ffb2..dced8c019514 100644
--- a/drivers/media/usb/go7007/snd-go7007.c
+++ b/drivers/media/usb/go7007/snd-go7007.c
@@ -243,6 +243,7 @@ int go7007_snd_init(struct go7007 *go)
 	ret = snd_device_new(gosnd->card, SNDRV_DEV_LOWLEVEL, go,
 			&go7007_snd_device_ops);
 	if (ret < 0) {
+		snd_card_free(gosnd->card);
 		kfree(gosnd);
 		return ret;
 	}
-- 
2.24.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] media: go7007: fix a miss of snd_card_free
  2019-12-06 12:07 [PATCH] media: go7007: fix a miss of snd_card_free Chuhong Yuan
@ 2019-12-06 14:10 ` Markus Elfring
  2019-12-06 14:37   ` Chuhong Yuan
  0 siblings, 1 reply; 4+ messages in thread
From: Markus Elfring @ 2019-12-06 14:10 UTC (permalink / raw)
  To: Chuhong Yuan, linux-media
  Cc: linux-kernel, Hans Verkuil, Mauro Carvalho Chehab, Dan Carpenter

> go7007_snd_init() misses a snd_card_free() in an error path.
> Add the missed call to fix it.

How do you think about to take another look also at the previous update suggestion
“[PATCH 5/6] [media] go7007: Use common error handling code in go7007_snd_init()”?
https://lore.kernel.org/linux-media/05efac78-3a14-803c-5b4a-68670728628b@users.sourceforge.net/
https://lore.kernel.org/patchwork/patch/831887/
https://lkml.org/lkml/2017/9/19/115

Regards,
Markus

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] media: go7007: fix a miss of snd_card_free
  2019-12-06 14:10 ` Markus Elfring
@ 2019-12-06 14:37   ` Chuhong Yuan
  2019-12-06 17:00     ` Markus Elfring
  0 siblings, 1 reply; 4+ messages in thread
From: Chuhong Yuan @ 2019-12-06 14:37 UTC (permalink / raw)
  To: Markus Elfring
  Cc: linux-media, LKML, Hans Verkuil, Mauro Carvalho Chehab, Dan Carpenter

On Fri, Dec 6, 2019 at 10:11 PM Markus Elfring <Markus.Elfring@web.de> wrote:
>
> > go7007_snd_init() misses a snd_card_free() in an error path.
> > Add the missed call to fix it.
>
> How do you think about to take another look also at the previous update suggestion
> “[PATCH 5/6] [media] go7007: Use common error handling code in go7007_snd_init()”?
> https://lore.kernel.org/linux-media/05efac78-3a14-803c-5b4a-68670728628b@users.sourceforge.net/
> https://lore.kernel.org/patchwork/patch/831887/
> https://lkml.org/lkml/2017/9/19/115
>

I think using goto is really much better than freeing after every error.
I will send a new version if others also agree with this pattern.

Regards,
Chuhong

> Regards,
> Markus

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: media: go7007: fix a miss of snd_card_free
  2019-12-06 14:37   ` Chuhong Yuan
@ 2019-12-06 17:00     ` Markus Elfring
  0 siblings, 0 replies; 4+ messages in thread
From: Markus Elfring @ 2019-12-06 17:00 UTC (permalink / raw)
  To: Chuhong Yuan, linux-media
  Cc: LKML, Hans Verkuil, Mauro Carvalho Chehab, Dan Carpenter

> I think using goto is really much better than freeing after every error.

Thanks for your positive feedback.


> I will send a new version if others also agree with this pattern.

* The error handling pattern would be supported by the Linux coding style.
  The agreement on corresponding changes can occasionally become more challenging.

* I would interpret Dan Carpenter's review comment (from 2017-09-19) in the way
  that he should be mentioned by the tag “Reported-by” in a subsequent patch.
  https://lkml.org/lkml/2017/9/19/115

Regards,
Markus

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-12-06 17:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-06 12:07 [PATCH] media: go7007: fix a miss of snd_card_free Chuhong Yuan
2019-12-06 14:10 ` Markus Elfring
2019-12-06 14:37   ` Chuhong Yuan
2019-12-06 17:00     ` Markus Elfring

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).