From: "Frank Schäfer" <fschaefer.oss@googlemail.com>
To: Mauro Carvalho Chehab <m.chehab@samsung.com>
Cc: Linux Media Mailing List <linux-media@vger.kernel.org>,
Mauro Carvalho Chehab <mchehab@infradead.org>
Subject: Re: [PATCH v3] em28xx: Only deallocate struct em28xx after finishing all extensions
Date: Sat, 08 Mar 2014 11:51:23 +0100 [thread overview]
Message-ID: <531AF62B.8000005@googlemail.com> (raw)
In-Reply-To: <20140307143803.61543333@samsung.com>
Am 07.03.2014 18:38, schrieb Mauro Carvalho Chehab:
>>> static int em28xx_usb_suspend(struct usb_interface *interface,
>>> > > diff --git a/drivers/media/usb/em28xx/em28xx-dvb.c b/drivers/media/usb/em28xx/em28xx-dvb.c
>>> > > index d4986bdfbdc3..6dbc71ba2820 100644
>>> > > --- a/drivers/media/usb/em28xx/em28xx-dvb.c
>>> > > +++ b/drivers/media/usb/em28xx/em28xx-dvb.c
>>> > > @@ -1043,7 +1043,6 @@ static int em28xx_dvb_init(struct em28xx *dev)
>>> > > em28xx_info("Binding DVB extension\n");
>>> > >
>>> > > dvb = kzalloc(sizeof(struct em28xx_dvb), GFP_KERNEL);
>>> > > -
>>> > > if (dvb == NULL) {
>>> > > em28xx_info("em28xx_dvb: memory allocation failed\n");
>>> > > return -ENOMEM;
>>> > > @@ -1521,6 +1520,9 @@ static int em28xx_dvb_init(struct em28xx *dev)
>>> > > dvb->adapter.mfe_shared = mfe_shared;
>>> > >
>>> > > em28xx_info("DVB extension successfully initialized\n");
>>> > > +
>>> > > + kref_get(&dev->ref);
>>> > > +
>> >
>> > The fini() functions are always called, even if an error occured in init().
>> > So (in opposition to the open()/close() functions) kref_get() needs to
>> > be called at the beginning of the init() methods.
>> >
>> > "dev->is_audio_only" and "!dev->board.has_dvb" is checked in both
>> > functions (init+fini), so the right place here is one line before or after
>> >
>> > em28xx_info("Binding DVB extension\n");
>> >
>> >
>> > Everything else looks good.
> I actually prefer to fix it the other way, at the code for kref_put()...
> see below
...
>> >
>> > Regards,
>> > Frank
>> >
>>> > > ret:
>>> > > em28xx_set_mode(dev, EM28XX_SUSPEND);
>>> > > mutex_unlock(&dev->lock);
>>> > > @@ -1579,6 +1581,8 @@ static int em28xx_dvb_fini(struct em28xx *dev)
>>> > > dev->dvb = NULL;
> Putting the kref_put() here. This part of the code is only called if
> dev->dvb it not NULL, and this is only possible to happen if the
> DVB is properly initialized.
Yes, that works, too.
Regards,
Frank
>
>>> > > }
>>> > >
>>> > > + kref_put(&dev->ref, em28xx_free_device);
>>> > > +
>>> > > return 0;
>>> > > }
next prev parent reply other threads:[~2014-03-08 10:50 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-12 23:00 [PATCH 0/7] Fix remaining issues with em28xx device removal Mauro Carvalho Chehab
2014-01-12 23:00 ` [PATCH 1/7] em28xx-audio: fix return code on device disconnect Mauro Carvalho Chehab
2014-01-13 18:38 ` Frank Schäfer
2014-01-12 23:00 ` [PATCH 2/7] em28xx-audio: simplify error handling Mauro Carvalho Chehab
2014-01-13 18:41 ` Frank Schäfer
2014-01-12 23:00 ` [PATCH 3/7] em28xx: Only deallocate struct em28xx after finishing all extensions Mauro Carvalho Chehab
2014-01-13 19:02 ` Frank Schäfer
2014-01-13 19:23 ` Mauro Carvalho Chehab
2014-01-13 21:55 ` Frank Schäfer
2014-01-14 13:10 ` Mauro Carvalho Chehab
2014-01-14 18:13 ` Frank Schäfer
2014-01-14 18:55 ` Mauro Carvalho Chehab
2014-01-14 19:31 ` Mauro Carvalho Chehab
2014-01-14 20:57 ` Frank Schäfer
2014-01-14 20:48 ` Frank Schäfer
2014-01-14 21:20 ` Mauro Carvalho Chehab
2014-01-15 18:48 ` Frank Schäfer
2014-01-14 17:36 ` [PATCH v2] " Mauro Carvalho Chehab
2014-01-15 21:13 ` Frank Schäfer
2014-02-09 18:41 ` Frank Schäfer
2014-02-09 20:09 ` Mauro Carvalho Chehab
2014-02-12 18:00 ` Frank Schäfer
2014-03-05 14:22 ` [PATCH v3] " Mauro Carvalho Chehab
2014-03-07 17:04 ` Frank Schäfer
2014-03-07 17:38 ` Mauro Carvalho Chehab
2014-03-08 10:51 ` Frank Schäfer [this message]
2014-01-12 23:00 ` [PATCH 4/7] em28xx-audio: disconnect before freeing URBs Mauro Carvalho Chehab
2014-01-13 18:47 ` Frank Schäfer
2014-01-12 23:00 ` [PATCH 5/7] em28xx-audio: remove a deplock circular dependency Mauro Carvalho Chehab
2014-01-13 21:51 ` Frank Schäfer
2014-01-14 15:45 ` Mauro Carvalho Chehab
2014-01-14 18:43 ` Frank Schäfer
2014-01-14 19:59 ` Mauro Carvalho Chehab
2014-01-14 20:51 ` Frank Schäfer
2014-01-12 23:00 ` [PATCH 6/7] em28xx: print a message at disconnect Mauro Carvalho Chehab
2014-01-13 18:51 ` Frank Schäfer
2014-01-12 23:00 ` [PATCH 7/7] em28xx: Fix usb diconnect logic Mauro Carvalho Chehab
2014-01-13 18:53 ` Frank Schäfer
2014-01-13 17:30 ` [PATCH 0/7] Fix remaining issues with em28xx device removal Antti Palosaari
2014-01-13 17:50 ` Mauro Carvalho Chehab
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=531AF62B.8000005@googlemail.com \
--to=fschaefer.oss@googlemail.com \
--cc=linux-media@vger.kernel.org \
--cc=m.chehab@samsung.com \
--cc=mchehab@infradead.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).