Skip to content

Commit 0b50b46

Browse files
Guomin.chenopsiff
authored andcommitted
drivers: gpu: drm: cix: Fixed potential NULL pointer issue.
This issue was caused by interface changes introduced by upstream: 9880702 Signed-off-by: Guomin.chen <Guomin.chen@cixtech.com>
1 parent ca5a67e commit 0b50b46

3 files changed

Lines changed: 15 additions & 4 deletions

File tree

drivers/gpu/drm/cix/dptx/trilin_dptx_cix.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ static uint32_t drm_acpi_crtc_port_mask(struct drm_device *dev,
9595
return 0;
9696
}
9797

98-
static uint32_t drm_acpi_find_possible_crtcs(struct drm_device *dev,
98+
static uint32_t __maybe_unused drm_acpi_find_possible_crtcs(struct drm_device *dev,
9999
struct fwnode_handle *port)
100100
{
101101
struct fwnode_handle *remote_port, *ep;
@@ -133,7 +133,7 @@ static int trilin_dptx_cix_bind(struct device *comp, struct device *master,
133133
encoder = &cix_dptx->encoder;
134134
if (has_acpi_companion(comp)) {
135135
np = comp->fwnode;
136-
encoder->possible_crtcs = drm_acpi_find_possible_crtcs(drm, np);
136+
encoder->possible_crtcs = 0x3; // always port@0,port@1 possible
137137
} else {
138138
np = comp->of_node;
139139
encoder->possible_crtcs = drm_of_find_possible_crtcs(drm, np);

drivers/gpu/drm/cix/linlon-dp/linlondp_dev.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ fwnode_graph_get_remote_node(const struct fwnode_handle *fwnode, u32 port_id,
2626
u32 endpoint_id)
2727
{
2828
struct fwnode_handle *endpoint = NULL;
29+
struct fwnode_reference_args args;
2930

3031
while ((endpoint = fwnode_graph_get_next_endpoint(fwnode, endpoint))) {
3132
struct fwnode_endpoint fwnode_ep;
@@ -39,10 +40,17 @@ fwnode_graph_get_remote_node(const struct fwnode_handle *fwnode, u32 port_id,
3940
if (fwnode_ep.port != port_id || fwnode_ep.id != endpoint_id)
4041
continue;
4142

43+
memset(&args, 0, sizeof(args));
44+
ret = acpi_node_get_property_reference(endpoint, "remote-endpoint", 0, &args);
45+
if (!ret && is_acpi_device_node(args.fwnode)) {
46+
pr_info("%s:%d get remote-endpoint device %s\n", __func__, __LINE__,
47+
dev_name(&to_acpi_device_node(args.fwnode)->dev));
48+
return args.fwnode;
49+
}
50+
4251
remote = fwnode_graph_get_remote_port_parent(endpoint);
4352
if (!remote)
4453
return NULL;
45-
4654
return fwnode_device_is_available(remote) ? remote : NULL;
4755
}
4856

drivers/gpu/drm/cix/linlon-dp/linlondp_drv.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,10 @@ static int linlondp_platform_probe(struct platform_device *pdev)
190190
LINLONDP_OF_PORT_OUTPUT, 1);
191191
}
192192
}
193-
pr_info("%s end. match=%p\n", __func__, match);
193+
if (!match) {
194+
pr_err("%s end. add slave component_match failed!\n", __func__);
195+
return -EINVAL;
196+
}
194197
return component_master_add_with_match(dev, &linlondp_master_ops,
195198
match);
196199
#else

0 commit comments

Comments
 (0)