Skip to content

Commit 1f119f9

Browse files
committed
Merge branch 'rds-bug-fixes'
Sowmini Varadhan says: ==================== rds bug fixes Ran into pre-existing bugs when working on the fix for https://www.spinics.net/lists/netdev/msg472849.html The bugs fixed in this patchset are unrelated to the syzbot failure (which I'm still testing and trying to reproduce) but meanwhile, let's get these fixes out of the way. V2: target net-next (rds:tcp patches have a dependancy on changes that are in net-next, but not yet in net) ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 3c14909 + 66261da commit 1f119f9

File tree

2 files changed

+28
-20
lines changed

2 files changed

+28
-20
lines changed

net/rds/bind.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ static int rds_add_bound(struct rds_sock *rs, __be32 addr, __be16 *port)
114114
rs, &addr, (int)ntohs(*port));
115115
break;
116116
} else {
117+
rs->rs_bound_addr = 0;
117118
rds_sock_put(rs);
118119
ret = -ENOMEM;
119120
break;

net/rds/tcp.c

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -270,16 +270,33 @@ static int rds_tcp_laddr_check(struct net *net, __be32 addr)
270270
return -EADDRNOTAVAIL;
271271
}
272272

273+
static void rds_tcp_conn_free(void *arg)
274+
{
275+
struct rds_tcp_connection *tc = arg;
276+
unsigned long flags;
277+
278+
rdsdebug("freeing tc %p\n", tc);
279+
280+
spin_lock_irqsave(&rds_tcp_conn_lock, flags);
281+
if (!tc->t_tcp_node_detached)
282+
list_del(&tc->t_tcp_node);
283+
spin_unlock_irqrestore(&rds_tcp_conn_lock, flags);
284+
285+
kmem_cache_free(rds_tcp_conn_slab, tc);
286+
}
287+
273288
static int rds_tcp_conn_alloc(struct rds_connection *conn, gfp_t gfp)
274289
{
275290
struct rds_tcp_connection *tc;
276-
int i;
291+
int i, j;
292+
int ret = 0;
277293

278294
for (i = 0; i < RDS_MPATH_WORKERS; i++) {
279295
tc = kmem_cache_alloc(rds_tcp_conn_slab, gfp);
280-
if (!tc)
281-
return -ENOMEM;
282-
296+
if (!tc) {
297+
ret = -ENOMEM;
298+
break;
299+
}
283300
mutex_init(&tc->t_conn_path_lock);
284301
tc->t_sock = NULL;
285302
tc->t_tinc = NULL;
@@ -290,27 +307,17 @@ static int rds_tcp_conn_alloc(struct rds_connection *conn, gfp_t gfp)
290307
tc->t_cpath = &conn->c_path[i];
291308

292309
spin_lock_irq(&rds_tcp_conn_lock);
310+
tc->t_tcp_node_detached = false;
293311
list_add_tail(&tc->t_tcp_node, &rds_tcp_conn_list);
294312
spin_unlock_irq(&rds_tcp_conn_lock);
295313
rdsdebug("rds_conn_path [%d] tc %p\n", i,
296314
conn->c_path[i].cp_transport_data);
297315
}
298-
299-
return 0;
300-
}
301-
302-
static void rds_tcp_conn_free(void *arg)
303-
{
304-
struct rds_tcp_connection *tc = arg;
305-
unsigned long flags;
306-
rdsdebug("freeing tc %p\n", tc);
307-
308-
spin_lock_irqsave(&rds_tcp_conn_lock, flags);
309-
if (!tc->t_tcp_node_detached)
310-
list_del(&tc->t_tcp_node);
311-
spin_unlock_irqrestore(&rds_tcp_conn_lock, flags);
312-
313-
kmem_cache_free(rds_tcp_conn_slab, tc);
316+
if (ret) {
317+
for (j = 0; j < i; j++)
318+
rds_tcp_conn_free(conn->c_path[j].cp_transport_data);
319+
}
320+
return ret;
314321
}
315322

316323
static bool list_has_conn(struct list_head *list, struct rds_connection *conn)

0 commit comments

Comments
 (0)