Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933806AbcDEWMg (ORCPT ); Tue, 5 Apr 2016 18:12:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35703 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760800AbcDEWMa (ORCPT ); Tue, 5 Apr 2016 18:12:30 -0400 Date: Tue, 5 Apr 2016 19:12:21 -0300 From: Marcelo Ricardo Leitner To: Bastien Philbert Cc: vyasevich@gmail.com, nhorman@tuxdriver.com, davem@davemloft.net, linux-sctp@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] sctp: Fix error handling for switch statement case in the function sctp_cmd_interprete Message-ID: <20160405221220.GA15005@localhost.localdomain> References: <1459892201-21397-1-git-send-email-bastienphilbert@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1459892201-21397-1-git-send-email-bastienphilbert@gmail.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 05 Apr 2016 22:12:24 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1744 Lines: 45 On Tue, Apr 05, 2016 at 05:36:41PM -0400, Bastien Philbert wrote: > This fixes error handling for the switch statement case > SCTP_CMD_SEND_PKT by making the error value of the call > to sctp_packet_transmit equal the variable error due to > this function being able to fail with a error code. In > addition allow the call to sctp_ootb_pkt_free afterwards > to free up the no longer in use sctp packet even if the > call to the function sctp_packet_transmit fails in order > to avoid a memory leak here for not freeing the sctp This leak shouldn't exist as sctp_packet_transmit() will free the packet if it returns ENOMEM, through the nomem: handling. But about making it visible to the user, that looks interesting to me although I cannot foresee yet its effects, like the comment at the end of sctp_packet_transmit() on not returning EHOSTUNREACH. Did you check it? > > Signed-off-by: Bastien Philbert > --- > net/sctp/sm_sideeffect.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c > index 7fe56d0..f3a8b58 100644 > --- a/net/sctp/sm_sideeffect.c > +++ b/net/sctp/sm_sideeffect.c > @@ -1434,7 +1434,7 @@ static int sctp_cmd_interpreter(sctp_event_t event_type, > case SCTP_CMD_SEND_PKT: > /* Send a full packet to our peer. */ > packet = cmd->obj.packet; > - sctp_packet_transmit(packet, gfp); > + error = sctp_packet_transmit(packet, gfp); > sctp_ootb_pkt_free(packet); > break; > > -- > 2.5.0 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-sctp" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html >