Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp712899ybi; Tue, 16 Jul 2019 04:11:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqznhfpk0X3L3gnoD58vg2pqkL4zwyRmLfngubSItIeISgPf8PSsdBkcQ802yLzVRLi4o0rE X-Received: by 2002:a17:902:8a94:: with SMTP id p20mr34341863plo.312.1563275499292; Tue, 16 Jul 2019 04:11:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563275499; cv=none; d=google.com; s=arc-20160816; b=o2gE0ku5UoeYWEf0Y8vjTt8Nlni4eOt79F6X+CowPt+V/NPPJY4a+8Cre6nOaC29MX uXIPebeuPH8JaLH3+sIsaD/eK7Ax1hOwihRvvQR41iiNYwP+FfojxAj0xovFJgd/9+JH 1CK2S6QT89ffu6lSTb8dVxylINbbQlzzZJucP7ngeasTQjkr1038Jgv3lSbNhTi1P/jz zMCdzIAM462Lx7d1yPMOJnzeue4vWuf+LjG2t7Y1I90mk/fg8N2ff7035PhP4qg3J7+y 7XSxfI7OxlL1OfOhu5Vvg878Orwn9MJjPqGKClXHxyINNW+8GCYNM8QEbR2qAdcJBMS6 YZNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=QAokbjexcUBSs4T/qhIylu/OK20lNfSJaENOUn/VrLU=; b=kSC8KV5VeNeLRTmEVscQagFFk2tbXGZ2Wb/ECKw6WTjJaLyhPH3+em4RurPh1TAsDF rRgtD6ZhdDCWbYnddpIBVNYxEoqDKP7MIxg4zkGKoAJslXtAUnT3lIPxxPFOfUQ1tlx4 IRSiU898w0uRxZq5Rfyy1A5qRcwi3PVfw0X5VSnOiycxCq07EuB56qKmQL+/aoTdLltG AD1f6kyRG7nh5iSVq1ktDeROAr6/qN0fYT3kTmGy33jaVWvlNIBjwXxtNdzvihJLF0Qo 1U0CtBuIA9i7MwCkVZ0+spUTT6PH2NP8cAjfGfrrdOrgV8d7e0BYz0T5CwjdBwsIphHP WMDw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q12si18463302pgv.225.2019.07.16.04.11.22; Tue, 16 Jul 2019 04:11:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387628AbfGPLKC (ORCPT + 99 others); Tue, 16 Jul 2019 07:10:02 -0400 Received: from charlotte.tuxdriver.com ([70.61.120.58]:37697 "EHLO smtp.tuxdriver.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733200AbfGPLKC (ORCPT ); Tue, 16 Jul 2019 07:10:02 -0400 Received: from cpe-2606-a000-111b-405a-0-0-0-162e.dyn6.twc.com ([2606:a000:111b:405a::162e] helo=localhost) by smtp.tuxdriver.com with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1hnLL9-0007ym-9m; Tue, 16 Jul 2019 07:09:58 -0400 Date: Tue, 16 Jul 2019 07:09:17 -0400 From: Neil Horman To: Hariprasad Kelam Cc: Vlad Yasevich , Marcelo Ricardo Leitner , "David S. Miller" , linux-sctp@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] net: sctp: fix warning "NULL check before some freeing functions is not needed" Message-ID: <20190716110917.GA1498@hmswarspite.think-freely.org> References: <20190716022002.GA19592@hari-Inspiron-1545> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190716022002.GA19592@hari-Inspiron-1545> User-Agent: Mutt/1.12.0 (2019-05-25) X-Spam-Score: -2.9 (--) X-Spam-Status: No Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 16, 2019 at 07:50:02AM +0530, Hariprasad Kelam wrote: > This patch removes NULL checks before calling kfree. > > fixes below issues reported by coccicheck > net/sctp/sm_make_chunk.c:2586:3-8: WARNING: NULL check before some > freeing functions is not needed. > net/sctp/sm_make_chunk.c:2652:3-8: WARNING: NULL check before some > freeing functions is not needed. > net/sctp/sm_make_chunk.c:2667:3-8: WARNING: NULL check before some > freeing functions is not needed. > net/sctp/sm_make_chunk.c:2684:3-8: WARNING: NULL check before some > freeing functions is not needed. > > Signed-off-by: Hariprasad Kelam > --- > net/sctp/sm_make_chunk.c | 12 ++++-------- > 1 file changed, 4 insertions(+), 8 deletions(-) > > diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c > index ed39396..36bd8a6e 100644 > --- a/net/sctp/sm_make_chunk.c > +++ b/net/sctp/sm_make_chunk.c > @@ -2582,8 +2582,7 @@ static int sctp_process_param(struct sctp_association *asoc, > case SCTP_PARAM_STATE_COOKIE: > asoc->peer.cookie_len = > ntohs(param.p->length) - sizeof(struct sctp_paramhdr); > - if (asoc->peer.cookie) > - kfree(asoc->peer.cookie); > + kfree(asoc->peer.cookie); > asoc->peer.cookie = kmemdup(param.cookie->body, asoc->peer.cookie_len, gfp); > if (!asoc->peer.cookie) > retval = 0; > @@ -2648,8 +2647,7 @@ static int sctp_process_param(struct sctp_association *asoc, > goto fall_through; > > /* Save peer's random parameter */ > - if (asoc->peer.peer_random) > - kfree(asoc->peer.peer_random); > + kfree(asoc->peer.peer_random); > asoc->peer.peer_random = kmemdup(param.p, > ntohs(param.p->length), gfp); > if (!asoc->peer.peer_random) { > @@ -2663,8 +2661,7 @@ static int sctp_process_param(struct sctp_association *asoc, > goto fall_through; > > /* Save peer's HMAC list */ > - if (asoc->peer.peer_hmacs) > - kfree(asoc->peer.peer_hmacs); > + kfree(asoc->peer.peer_hmacs); > asoc->peer.peer_hmacs = kmemdup(param.p, > ntohs(param.p->length), gfp); > if (!asoc->peer.peer_hmacs) { > @@ -2680,8 +2677,7 @@ static int sctp_process_param(struct sctp_association *asoc, > if (!ep->auth_enable) > goto fall_through; > > - if (asoc->peer.peer_chunks) > - kfree(asoc->peer.peer_chunks); > + kfree(asoc->peer.peer_chunks); > asoc->peer.peer_chunks = kmemdup(param.p, > ntohs(param.p->length), gfp); > if (!asoc->peer.peer_chunks) > -- > 2.7.4 > > Acked-by: Neil Horman