From patchwork Thu May 25 20:35:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Dickson X-Patchwork-Id: 9749123 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DE50C60246 for ; Thu, 25 May 2017 20:35:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D13C8283AF for ; Thu, 25 May 2017 20:35:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C4868283C3; Thu, 25 May 2017 20:35:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 68782283AF for ; Thu, 25 May 2017 20:35:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1764183AbdEYUfq (ORCPT ); Thu, 25 May 2017 16:35:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38168 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1763386AbdEYUfp (ORCPT ); Thu, 25 May 2017 16:35:45 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7AD568051D for ; Thu, 25 May 2017 20:35:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7AD568051D Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=steved@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 7AD568051D Received: from steved.boston.devel.redhat.com (ovpn-122-191.rdu2.redhat.com [10.10.122.191]) by smtp.corp.redhat.com (Postfix) with ESMTP id 29591189B1 for ; Thu, 25 May 2017 20:35:34 +0000 (UTC) From: Steve Dickson To: Linux NFS Mailing list Subject: [PATCH 2/2] rpcbproc_callit_com: No need to allocate output buffer Date: Thu, 25 May 2017 16:35:31 -0400 Message-Id: <20170525203531.4471-2-steved@redhat.com> In-Reply-To: <20170525203531.4471-1-steved@redhat.com> References: <20170525203531.4471-1-steved@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 25 May 2017 20:35:34 +0000 (UTC) Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Now that sendz is a fixed size (UDPMSGSIZE) which is small then RPC_BUF_MAX, no need to check the sendz size. Signed-off-by: Steve Dickson --- src/rpcb_svc_com.c | 33 +++++---------------------------- 1 file changed, 5 insertions(+), 28 deletions(-) diff --git a/src/rpcb_svc_com.c b/src/rpcb_svc_com.c index 1fc2229..d36b090 100644 --- a/src/rpcb_svc_com.c +++ b/src/rpcb_svc_com.c @@ -612,8 +612,6 @@ rpcbproc_callit_com(struct svc_req *rqstp, SVCXPRT *transp, struct netconfig *nconf; struct netbuf *caller; struct r_rmtcall_args a; - char *outbufp; - char *outbuf_alloc = NULL; char outbuf[RPC_BUF_MAX]; struct netbuf *na = (struct netbuf *) NULL; struct rpc_msg call_msg; @@ -674,7 +672,6 @@ rpcbproc_callit_com(struct svc_req *rqstp, SVCXPRT *transp, rpcbs_rmtcall(versnum - 2, reply_type, a.rmt_prog, a.rmt_vers, a.rmt_proc, transp->xp_netid, rbl); - if (rbl == (rpcblist_ptr)NULL) { #ifdef RPCBIND_DEBUG if (debugging) @@ -793,24 +790,10 @@ rpcbproc_callit_com(struct svc_req *rqstp, SVCXPRT *transp, call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION; call_msg.rm_call.cb_prog = a.rmt_prog; call_msg.rm_call.cb_vers = a.rmt_vers; - if (sendsz > RPC_BUF_MAX) { -#ifdef notyet - outbuf_alloc = alloca(sendsz); /* not in IDR2? */ -#else - outbuf_alloc = malloc(sendsz); -#endif /* notyet */ - if (outbuf_alloc == NULL) { - if (reply_type == RPCBPROC_INDIRECT) - svcerr_systemerr(transp); - if (debugging) - xlog(LOG_DEBUG, - "rpcbproc_callit_com: No memory!\n"); - goto error; - } - xdrmem_create(&outxdr, outbuf_alloc, sendsz, XDR_ENCODE); - } else { - xdrmem_create(&outxdr, outbuf, sendsz, XDR_ENCODE); - } + + memset(outbuf, '\0', sendsz); /* Zero out the output buffer */ + xdrmem_create(&outxdr, outbuf, sendsz, XDR_ENCODE); + if (!xdr_callhdr(&outxdr, &call_msg)) { if (reply_type == RPCBPROC_INDIRECT) svcerr_systemerr(transp); @@ -875,10 +858,6 @@ rpcbproc_callit_com(struct svc_req *rqstp, SVCXPRT *transp, goto error; } outlen = (int) XDR_GETPOS(&outxdr); - if (outbuf_alloc) - outbufp = outbuf_alloc; - else - outbufp = outbuf; na = uaddr2taddr(nconf, local_uaddr); if (!na) { @@ -887,7 +866,7 @@ rpcbproc_callit_com(struct svc_req *rqstp, SVCXPRT *transp, goto error; } - if (sendto(fd, outbufp, outlen, 0, (struct sockaddr *)na->buf, na->len) + if (sendto(fd, outbuf, outlen, 0, (struct sockaddr *)na->buf, na->len) != outlen) { if (debugging) xlog(LOG_DEBUG, @@ -912,8 +891,6 @@ out: } if (local_uaddr) free(local_uaddr); - if (outbuf_alloc) - free(outbuf_alloc); if (na) { free(na->buf); free(na);