<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/drivers/base/component.c, branch v4.5</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
</subtitle>
<id>https://git.shady.money/linux/atom?h=v4.5</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v4.5'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2016-02-11T09:42:09Z</updated>
<entry>
<title>component: remove device from master match list on failed add</title>
<updated>2016-02-11T09:42:09Z</updated>
<author>
<name>Daniel Stone</name>
<email>daniels@collabora.com</email>
</author>
<published>2016-02-08T21:12:58Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=8e7199c2c50fff1969302643171eaa33f1ca148f'/>
<id>urn:sha1:8e7199c2c50fff1969302643171eaa33f1ca148f</id>
<content type='text'>
Calling component_add() may result in the completion of a set of
devices, which will try to bring up a master. In bringing the master
up, we populate its match array with the current set of children.

If binding any of the devices fails, component_add() itself will fail,
free the struct component entry, and return to the caller. The
now-freed entry is never removed from the master's match array, and
will later be used in a futile attempt to bind to freed memory.

Bring component_add's behaviour on failure to bring up a master into
line with component_del by removing the (to-be-freed) component from
the master's match array.

The specific case which broke was:
  - rockchip_drm_drv adds a component master
  - dwhdmi_rockchip adds a child component in probe (master incomplete)
  - rockchip_drm_vop adds two children in probe, which completes the
    set
  - inside component_add, we try to bring up the master, having
    populated the master's match array, and fail with EPROBE_DEFER from
    dwhdmi_rockchip; we delete the putative component
  - rockchip_drm_vop's probe fails and returns EPROBE_DEFER
  - we later re-probe rockchip_drm_vop and add the component; the
    master is complete, so we attempt to bring it up again
  - walking the match array, we find the previous child, whose master
    pointer doesn't match (as it has been freed in the meantime)
  - rockchip_drm_vop probe fails, and will never be attempted again

Fixes: ffc30b74fd6d01588bd3fdebc3b1acc0857e6fc8
Signed-off-by: Daniel Stone &lt;daniels@collabora.com&gt;
Cc: Russell King &lt;rmk+kernel@arm.linux.org.uk&gt;
Cc: Thierry Reding &lt;treding@nvidia.com&gt;
Cc: Laurent Pinchart &lt;laurent.pinchart@ideasonboard.com&gt;
Signed-off-by: Russell King &lt;rmk+kernel@arm.linux.org.uk&gt;
</content>
</entry>
<entry>
<title>component: Detach components when deleting master struct</title>
<updated>2016-01-27T19:07:51Z</updated>
<author>
<name>Jon Medhurst (Tixy)</name>
<email>tixy@linaro.org</email>
</author>
<published>2016-01-26T17:59:13Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=57480484f9f7631738ef28b952eca3c9081c4291'/>
<id>urn:sha1:57480484f9f7631738ef28b952eca3c9081c4291</id>
<content type='text'>
component_master_add_with_match calls find_components which, if any
components already exist, it attaches to the master struct. However, if
we later encounter an error the master struct is deleted, leaving
components with a dangling pointer to it.

If the error was a temporary one, e.g. for probe deferral, then when
the master device is re-probed, it will fail to find the required
components as they appear to already be attached to a master.

Fix this by nulling components pointers to the master struct when it is
deleted. This code is factored out into a separate function so it can be
shared with component_master_del.

Signed-off-by: Jon Medhurst &lt;tixy@linaro.org&gt;
Signed-off-by: Russell King &lt;rmk+kernel@arm.linux.org.uk&gt;
</content>
</entry>
<entry>
<title>component: fix crash on x86_64 with hda audio drivers</title>
<updated>2016-01-26T18:13:33Z</updated>
<author>
<name>Russell King</name>
<email>rmk+kernel@arm.linux.org.uk</email>
</author>
<published>2016-01-26T14:49:22Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=9a4e7849b5e4e8742d71fa90fbf0722dd0710a56'/>
<id>urn:sha1:9a4e7849b5e4e8742d71fa90fbf0722dd0710a56</id>
<content type='text'>
Maarten reports that the addition of releasing match data to the
component helper results in a general protection fault on x86_64.

This is caused by the devm resources being freed in reverse order
to their allocation, which caused a use-after-free of the match
array.

Switch the match array to be a more conventional kmalloc/kfree()
affair, explicitly freeing it along with the parent match data
structure.

Reported-by: Maarten Lankhorst &lt;maarten.lankhorst@linux.intel.com&gt;
Fixes: ce657b1cddf1 ("component: add support for releasing match data")
Signed-off-by: Russell King &lt;rmk+kernel@arm.linux.org.uk&gt;
</content>
</entry>
<entry>
<title>component: add support for releasing match data</title>
<updated>2015-12-07T00:02:05Z</updated>
<author>
<name>Russell King</name>
<email>rmk+kernel@arm.linux.org.uk</email>
</author>
<published>2015-11-17T12:08:01Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=ce657b1cddf1f88c56ae683efa7130341c92808b'/>
<id>urn:sha1:ce657b1cddf1f88c56ae683efa7130341c92808b</id>
<content type='text'>
The component helper treats the void match data pointer as an opaque
object which needs no further management.  When device nodes being
passed, this is not true: the caller should pass its refcount to the
component helper, and there should be a way to drop the refcount when
the matching information is destroyed.

This patch provides a per-match release method in addition to the match
method to solve this issue.  Rather than using component_match_add(),
users should use component_match_add_release() which takes an additional
function pointer for releasing this reference.

Signed-off-by: Russell King &lt;rmk+kernel@arm.linux.org.uk&gt;
</content>
</entry>
<entry>
<title>component: track components via array rather than list</title>
<updated>2015-12-07T00:02:05Z</updated>
<author>
<name>Russell King</name>
<email>rmk+kernel@arm.linux.org.uk</email>
</author>
<published>2014-04-18T22:05:53Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=ffc30b74fd6d01588bd3fdebc3b1acc0857e6fc8'/>
<id>urn:sha1:ffc30b74fd6d01588bd3fdebc3b1acc0857e6fc8</id>
<content type='text'>
Since we now have an array which defines each component, maintain the
components to be bound in the array rather than a separate list.  We
also need duplicate tracking so we can eliminate multiple bind calls
for the same component: we preserve the list-based component order in
that the first match which adds the component determines its position.

Signed-off-by: Russell King &lt;rmk+kernel@arm.linux.org.uk&gt;
</content>
</entry>
<entry>
<title>component: move check for unbound master into try_to_bring_up_masters()</title>
<updated>2015-12-07T00:02:04Z</updated>
<author>
<name>Russell King</name>
<email>rmk+kernel@arm.linux.org.uk</email>
</author>
<published>2014-04-23T09:46:11Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=29f1c7fd61a31e0335ce41d4b2788959ad7c468d'/>
<id>urn:sha1:29f1c7fd61a31e0335ce41d4b2788959ad7c468d</id>
<content type='text'>
Clean up the code a little; we don't need to check that the master is
unbound for every invocation of try_to_bring_up_master(), so let's move
it to where it's really needed - try_to_bring_up_masters(), where we may
encounter already bound masters.

Reviewed-by: Thierry Reding &lt;treding@nvidia.com&gt;
Signed-off-by: Russell King &lt;rmk+kernel@arm.linux.org.uk&gt;
</content>
</entry>
<entry>
<title>component: remove old add_components method</title>
<updated>2015-12-07T00:02:00Z</updated>
<author>
<name>Russell King</name>
<email>rmk+kernel@arm.linux.org.uk</email>
</author>
<published>2014-04-18T21:10:32Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=fae9e2e07af07baabb8c26a31b3f7d8fdf89809e'/>
<id>urn:sha1:fae9e2e07af07baabb8c26a31b3f7d8fdf89809e</id>
<content type='text'>
Now that drivers create an array of component matches at probe time, we
can retire the old methods.  This involves removing the add_components
master method, and removing component_master_add_child() from public
view.  We also remove component_add_master() as that interface is no
longer useful.

Acked-by: Andrew Lunn &lt;andrew@lunn.ch&gt;
Signed-off-by: Russell King &lt;rmk+kernel@arm.linux.org.uk&gt;
</content>
</entry>
<entry>
<title>component: fix bug with legacy API</title>
<updated>2014-07-04T17:05:05Z</updated>
<author>
<name>Russell King</name>
<email>rmk+kernel@arm.linux.org.uk</email>
</author>
<published>2014-07-04T12:23:46Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=b509cc802239a8b5ba7d1d2cc5adfb9d984b7ed8'/>
<id>urn:sha1:b509cc802239a8b5ba7d1d2cc5adfb9d984b7ed8</id>
<content type='text'>
Sachin Kamat reports that "component: add support for component match
array" broke Exynos DRM due to a NULL pointer deref.  Fix this.

Reported-by: Sachin Kamat &lt;sachin.kamat@samsung.com&gt;
Tested-by: Sachin Kamat &lt;sachin.kamat@samsung.com&gt;
Signed-off-by: Russell King &lt;rmk+kernel@arm.linux.org.uk&gt;
</content>
</entry>
<entry>
<title>component: add support for component match array</title>
<updated>2014-07-03T10:32:43Z</updated>
<author>
<name>Russell King</name>
<email>rmk+kernel@arm.linux.org.uk</email>
</author>
<published>2014-04-19T10:18:01Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=6955b58254c2bcee8a7b55ce06468a645dc98ec5'/>
<id>urn:sha1:6955b58254c2bcee8a7b55ce06468a645dc98ec5</id>
<content type='text'>
Add support for generating a set of component matches at master probe
time, and submitting them to the component layer.  This allows the
component layer to perform the matches internally without needing to
call into the master driver, and allows for further restructuring of
the component helper.

Acked-by: Laurent Pinchart &lt;laurent.pinchart@ideasonboard.com&gt;
Signed-off-by: Russell King &lt;rmk+kernel@arm.linux.org.uk&gt;
</content>
</entry>
<entry>
<title>component: ignore multiple additions of the same component</title>
<updated>2014-07-03T10:32:40Z</updated>
<author>
<name>Russell King</name>
<email>rmk+kernel@arm.linux.org.uk</email>
</author>
<published>2014-04-18T19:16:22Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=fcbcebce7159c928692dc6a5e88869f6e44438b9'/>
<id>urn:sha1:fcbcebce7159c928692dc6a5e88869f6e44438b9</id>
<content type='text'>
Permit masters to call component_master_add_child() and match the same
child multiple times.  This may happen if there's multiple connections
to a single component device from other devices.  In such scenarios,
we should not return a failure, but instead ignore the attempt.

Acked-by: Laurent Pinchart &lt;laurent.pinchart@ideasonboard.com&gt;
Signed-off-by: Russell King &lt;rmk+kernel@arm.linux.org.uk&gt;
</content>
</entry>
</feed>
