|
@@ -1055,6 +1055,18 @@ static void dp_mst_sim_notify(struct dp_mst_sim_context *ctx,
|
|
queue_work(ctx->wq, &work->base);
|
|
queue_work(ctx->wq, &work->base);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+static void dp_mst_sim_free_ports(struct dp_mst_sim_context *ctx)
|
|
|
|
+{
|
|
|
|
+ u32 i;
|
|
|
|
+
|
|
|
|
+ for (i = 0; i < ctx->port_num; i++)
|
|
|
|
+ kfree(ctx->ports[i].edid);
|
|
|
|
+
|
|
|
|
+ kfree(ctx->ports);
|
|
|
|
+ ctx->ports = NULL;
|
|
|
|
+ ctx->port_num = 0;
|
|
|
|
+}
|
|
|
|
+
|
|
int dp_mst_sim_update(void *mst_sim_context, u32 port_num,
|
|
int dp_mst_sim_update(void *mst_sim_context, u32 port_num,
|
|
struct dp_mst_sim_port *ports)
|
|
struct dp_mst_sim_port *ports)
|
|
{
|
|
{
|
|
@@ -1064,7 +1076,7 @@ int dp_mst_sim_update(void *mst_sim_context, u32 port_num,
|
|
u32 update_mask = 0;
|
|
u32 update_mask = 0;
|
|
u32 i;
|
|
u32 i;
|
|
|
|
|
|
- if (!ctx || port_num >= 15)
|
|
|
|
|
|
+ if (!ctx || port_num >= 15 || !ports)
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
|
|
|
|
mutex_lock(&ctx->session_lock);
|
|
mutex_lock(&ctx->session_lock);
|
|
@@ -1081,19 +1093,17 @@ int dp_mst_sim_update(void *mst_sim_context, u32 port_num,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- for (i = 0; i < ctx->port_num; i++)
|
|
|
|
- kfree(ctx->ports[i].edid);
|
|
|
|
- kfree(ctx->ports);
|
|
|
|
- ctx->port_num = 0;
|
|
|
|
|
|
+ dp_mst_sim_free_ports(ctx);
|
|
|
|
|
|
- if (port_num) {
|
|
|
|
- ctx->ports = kcalloc(port_num, sizeof(*ports), GFP_KERNEL);
|
|
|
|
- if (!ctx->ports) {
|
|
|
|
- rc = -ENOMEM;
|
|
|
|
- goto fail;
|
|
|
|
- }
|
|
|
|
- ctx->port_num = port_num;
|
|
|
|
|
|
+ if (!port_num)
|
|
|
|
+ goto end;
|
|
|
|
+
|
|
|
|
+ ctx->ports = kcalloc(port_num, sizeof(*ports), GFP_KERNEL);
|
|
|
|
+ if (!ctx->ports) {
|
|
|
|
+ rc = -ENOMEM;
|
|
|
|
+ goto fail;
|
|
}
|
|
}
|
|
|
|
+ ctx->port_num = port_num;
|
|
|
|
|
|
for (i = 0; i < port_num; i++) {
|
|
for (i = 0; i < port_num; i++) {
|
|
ctx->ports[i] = ports[i];
|
|
ctx->ports[i] = ports[i];
|
|
@@ -1116,13 +1126,10 @@ int dp_mst_sim_update(void *mst_sim_context, u32 port_num,
|
|
}
|
|
}
|
|
|
|
|
|
fail:
|
|
fail:
|
|
- if (rc) {
|
|
|
|
- for (i = 0; i < ctx->port_num; i++)
|
|
|
|
- kfree(ctx->ports[i].edid);
|
|
|
|
- kfree(ctx->ports);
|
|
|
|
- ctx->port_num = 0;
|
|
|
|
- }
|
|
|
|
|
|
+ if (rc)
|
|
|
|
+ dp_mst_sim_free_ports(ctx);
|
|
|
|
|
|
|
|
+end:
|
|
mutex_unlock(&ctx->session_lock);
|
|
mutex_unlock(&ctx->session_lock);
|
|
|
|
|
|
if (update_mask)
|
|
if (update_mask)
|