mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	sctp: only drop the reference on the datamsg after sending a msg
If the chunks are enqueued successfully but sctp_cmd_interpreter() return err to sctp_sendmsg() (mainly because of no mem), the chunks will get re-queued, but we are dropping the reference and freeing them. The fix is to just drop the reference on the datamsg just as it had succeeded, as: - if the chunks weren't queued, this is enough to get them freed. - if they were queued, they will get freed when they finally get out or discarded. Signed-off-by: Xin Long <lucien.xin@gmail.com> Marcelo Ricardo Leitner <marcelo.leitner@gmail.com> Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
		
							parent
							
								
									69b5777f2e
								
							
						
					
					
						commit
						8b570dc9f7
					
				
					 1 changed files with 2 additions and 4 deletions
				
			
		| 
						 | 
					@ -1964,15 +1964,13 @@ static int sctp_sendmsg(struct sock *sk, struct msghdr *msg, size_t msg_len)
 | 
				
			||||||
	 * breaks.
 | 
						 * breaks.
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	err = sctp_primitive_SEND(net, asoc, datamsg);
 | 
						err = sctp_primitive_SEND(net, asoc, datamsg);
 | 
				
			||||||
 | 
						sctp_datamsg_put(datamsg);
 | 
				
			||||||
	/* Did the lower layer accept the chunk? */
 | 
						/* Did the lower layer accept the chunk? */
 | 
				
			||||||
	if (err) {
 | 
						if (err)
 | 
				
			||||||
		sctp_datamsg_free(datamsg);
 | 
					 | 
				
			||||||
		goto out_free;
 | 
							goto out_free;
 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pr_debug("%s: we sent primitively\n", __func__);
 | 
						pr_debug("%s: we sent primitively\n", __func__);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	sctp_datamsg_put(datamsg);
 | 
					 | 
				
			||||||
	err = msg_len;
 | 
						err = msg_len;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (unlikely(wait_connect)) {
 | 
						if (unlikely(wait_connect)) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue