From: Sylwester Nawrocki <s.nawrocki@samsung.com>
To: Mauro Carvalho Chehab <m.chehab@samsung.com>,
Hans Verkuil <hverkuil@xs4all.nl>
Cc: Linux Media Mailing List <linux-media@vger.kernel.org>,
Mauro Carvalho Chehab <mchehab@infradead.org>,
Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Subject: Re: [PATCHv2 22/29] v4l2-async: Don't use dynamic static allocation
Date: Tue, 05 Nov 2013 12:42:23 +0100 [thread overview]
Message-ID: <5278D99F.5050508@samsung.com> (raw)
In-Reply-To: <20131105093628.6da1a600@samsung.com>
On 05/11/13 12:36, Mauro Carvalho Chehab wrote:
>>> diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c
>>> > > index c85d69da35bd..071596869036 100644
>>> > > --- a/drivers/media/v4l2-core/v4l2-async.c
>>> > > +++ b/drivers/media/v4l2-core/v4l2-async.c
>>> > > @@ -189,12 +189,14 @@ void v4l2_async_notifier_unregister(struct v4l2_async_notifier *notifier)
>>> > > struct v4l2_subdev *sd, *tmp;
>>> > > unsigned int notif_n_subdev = notifier->num_subdevs;
>>> > > unsigned int n_subdev = min(notif_n_subdev, V4L2_MAX_SUBDEVS);
>>> > > - struct device *dev[n_subdev];
>>> > > + struct device **dev;
>>> > > int i = 0;
>>> > >
>>> > > if (!notifier->v4l2_dev)
>>> > > return;
>>> > >
>>> > > + dev = kmalloc(sizeof(*dev) * n_subdev, GFP_KERNEL);
>>> > > +
>> >
>> > No check for dev == NULL?
> Well, what should be done in this case?
>
> We could do the changes below:
>
> void v4l2_async_notifier_unregister(struct v4l2_async_notifier *notifier)
> {
> struct v4l2_subdev *sd, *tmp;
> unsigned int notif_n_subdev = notifier->num_subdevs;
> unsigned int n_subdev = min(notif_n_subdev, V4L2_MAX_SUBDEVS);
> - struct device *dev[n_subdev];
> + struct device **dev;
> int i = 0;
>
> if (!notifier->v4l2_dev)
> return;
>
> + dev = kmalloc(sizeof(*dev) * n_subdev, GFP_KERNEL);
> + if (!dev) {
> + WARN_ON(true);
> + return;
> + }
> +
> mutex_lock(&list_lock);
>
> list_del(¬ifier->list);
>
> list_for_each_entry_safe(sd, tmp, ¬ifier->done, async_list) {
> dev[i] = get_device(sd->dev);
>
> v4l2_async_cleanup(sd);
>
> /* If we handled USB devices, we'd have to lock the parent too */
> device_release_driver(dev[i++]);
>
> if (notifier->unbind)
> notifier->unbind(notifier, sd, sd->asd);
> }
>
> mutex_unlock(&list_lock);
>
> while (i--) {
> struct device *d = dev[i];
>
> if (d && device_attach(d) < 0) {
> const char *name = "(none)";
> int lock = device_trylock(d);
>
> if (lock && d->driver)
> name = d->driver->name;
> dev_err(d, "Failed to re-probe to %s\n", name);
> if (lock)
> device_unlock(d);
> }
> put_device(d);
> }
> + kfree(dev);
>
> notifier->v4l2_dev = NULL;
>
> /*
> * Don't care about the waiting list, it is initialised and populated
> * upon notifier registration.
> */
> }
> EXPORT_SYMBOL(v4l2_async_notifier_unregister);
>
> But I suspect that this will cause an OOPS anyway, as the device will be
> only half-removed. So, it would likely OOPS at device removal or if the
> device got probed again, at probing time.
>
> So, IMHO, we should have at least a WARN_ON() for this case.
>
> Do you have a better idea?
This is how Guennadi's patch looked like when it used dynamic allocation:
http://www.spinics.net/lists/linux-sh/msg18194.html
--
Regards,
Sylwester
next prev parent reply other threads:[~2013-11-05 11:42 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-02 13:31 [PATCHv2 00/29] Fix errors/warnings with allmodconfig/allyesconfig on non-x86 archs Mauro Carvalho Chehab
2013-11-02 13:31 ` [PATCHv2 01/29] tda9887: remove an warning when compiling for alpha Mauro Carvalho Chehab
2013-11-02 13:31 ` [PATCHv2 02/29] radio-shark: remove a warning when CONFIG_PM is not defined Mauro Carvalho Chehab
2013-11-02 13:31 ` [PATCHv2 03/29] zoran: don't build it on alpha Mauro Carvalho Chehab
2013-11-02 13:31 ` [PATCHv2 04/29] cx18: struct i2c_client is too big for stack Mauro Carvalho Chehab
2013-11-02 13:31 ` [PATCHv2 05/29] tef6862: fix warning on avr32 arch Mauro Carvalho Chehab
2013-11-02 13:31 ` [PATCHv2 06/29] iguanair: shut up a gcc " Mauro Carvalho Chehab
2013-11-03 22:10 ` Sean Young
2013-11-03 22:13 ` [PATCH] [media] iguanair: simplify calculation of carrier delay cycles Sean Young
2013-11-02 13:31 ` [PATCHv2 07/29] platform drivers: Fix build on cris and frv archs Mauro Carvalho Chehab
2013-11-04 4:03 ` Ben Hutchings
2013-11-04 11:28 ` Mauro Carvalho Chehab
2013-11-02 13:31 ` [PATCHv2 08/29] cx18: disable compilation on frv arch Mauro Carvalho Chehab
2013-11-02 13:31 ` [PATCHv2 09/29] radio-si470x-i2c: fix a warning on ia64 Mauro Carvalho Chehab
2013-11-02 13:31 ` [PATCHv2 10/29] rc: Fir warnings on m68k arch Mauro Carvalho Chehab
2013-11-02 13:31 ` [PATCHv2 11/29] uvc/lirc_serial: Fix some warnings on parisc arch Mauro Carvalho Chehab
2013-11-04 14:22 ` Laurent Pinchart
2013-11-04 14:43 ` Mauro Carvalho Chehab
2013-11-02 13:31 ` [PATCHv2 12/29] s5h1420: Don't use dynamic static allocation Mauro Carvalho Chehab
2013-11-02 13:31 ` [PATCHv2 13/29] dvb-frontends: " Mauro Carvalho Chehab
2013-11-02 13:31 ` [PATCHv2 14/29] " Mauro Carvalho Chehab
2013-11-02 17:10 ` Antti Palosaari
2013-11-02 13:31 ` [PATCHv2 15/29] stb0899_drv: " Mauro Carvalho Chehab
2013-11-02 13:31 ` [PATCHv2 16/29] stv0367: " Mauro Carvalho Chehab
2013-11-02 13:31 ` [PATCHv2 17/29] stv090x: " Mauro Carvalho Chehab
2013-11-02 13:31 ` [PATCHv2 18/29] av7110_hw: " Mauro Carvalho Chehab
2013-11-02 13:31 ` [PATCHv2 19/29] tuners: " Mauro Carvalho Chehab
2013-11-02 17:12 ` Antti Palosaari
2013-11-02 17:25 ` Hans Verkuil
2013-11-02 21:15 ` Mauro Carvalho Chehab
2013-11-02 21:53 ` Hans Verkuil
2013-11-02 21:59 ` Hans Verkuil
2013-11-03 0:21 ` Mauro Carvalho Chehab
2013-11-03 9:12 ` Mauro Carvalho Chehab
2013-11-03 11:54 ` Antti Palosaari
2013-11-04 13:26 ` Hans Verkuil
2013-11-04 14:24 ` Mauro Carvalho Chehab
2013-11-02 13:31 ` [PATCHv2 20/29] tuner-xc2028: " Mauro Carvalho Chehab
2013-11-02 13:31 ` [PATCHv2 21/29] cimax2: " Mauro Carvalho Chehab
2013-11-02 13:31 ` [PATCHv2 22/29] v4l2-async: " Mauro Carvalho Chehab
2013-11-04 13:15 ` Hans Verkuil
2013-11-05 11:36 ` Mauro Carvalho Chehab
2013-11-05 11:42 ` Sylwester Nawrocki [this message]
2013-11-05 12:03 ` Mauro Carvalho Chehab
2013-11-05 12:35 ` Hans Verkuil
2013-11-05 13:16 ` Mauro Carvalho Chehab
2013-11-05 14:18 ` Hans Verkuil
2013-11-02 13:31 ` [PATCHv2 23/29] cxusb: " Mauro Carvalho Chehab
2013-11-02 13:31 ` [PATCHv2 24/29] dibusb-common: " Mauro Carvalho Chehab
2013-11-02 13:31 ` [PATCHv2 25/29] dw2102: " Mauro Carvalho Chehab
2013-11-02 13:31 ` [PATCHv2 26/29] af9015: " Mauro Carvalho Chehab
2013-11-02 17:05 ` Antti Palosaari
2013-11-02 13:31 ` [PATCHv2 27/29] af9035: " Mauro Carvalho Chehab
2013-11-02 17:19 ` Antti Palosaari
2013-11-02 13:31 ` [PATCHv2 28/29] mxl111sf: " Mauro Carvalho Chehab
2013-11-04 0:50 ` Michael Krufky
2013-11-04 10:58 ` Mauro Carvalho Chehab
2013-11-04 11:04 ` Michael Krufky
2013-11-02 13:31 ` [PATCHv2 29/29] lirc_zilog: " 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=5278D99F.5050508@samsung.com \
--to=s.nawrocki@samsung.com \
--cc=g.liakhovetski@gmx.de \
--cc=hverkuil@xs4all.nl \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.