From patchwork Tue Sep 3 06:58:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 172780 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp5276378ily; Mon, 2 Sep 2019 23:58:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqxFbI8eEOD0uiEkQzjTJhRTvmNGaRwfJ5kvBUuYsa+7ghaVr3xvYAYNU0dEHg+MwK4hjP9b X-Received: by 2002:a62:1685:: with SMTP id 127mr39080408pfw.122.1567493934591; Mon, 02 Sep 2019 23:58:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567493934; cv=none; d=google.com; s=arc-20160816; b=WB5pH+Ff9lztfrVZ+QBakXQZ2gNi4nTgz2Vx5Km0wMocjsc77kS0dVXveaD+z1sJno SFaYxB9fOTATV7aFUrqJ9kuiPji0N/OmrnBOdga4LvWdrJeGQS382IDVjBsbHnJ1xCzO GN3YFjvUuyIuYPdsOEFjtqpAvBBfTE9bvai8sW8J0SlVYAd4C2pkWopwOoLG0xSc6hjM PT8jvfOF9biAgbIWuB0YSMAAe+V1YqxS3UELBugbi0fF0wLazwK8JgiMUqgTRRAYRT42 9kkkoTZmJFwVDnI0FT90tJ8Mhkva3UyLzOWoLIigv8xF+rS0Wbef6FBaAsfnIfP2GkQ2 +WFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=uoHHEgFr/r/SO8I5nMCow7X4j/JyWHdeMkJD+GMFPiE=; b=UcIy31LoiPuehNE7dqxQHNdIGPHlPJIdw3+bVc9fXHxRlTOja8R/R+F+RkKfBErlpC zvdCkRFpS3WPuKYUUFlbPATRSzI9fV6ppgBg01fWWlW+k4uOA4v7VUWdnhA9f/Jjomme dAQssLWNUN1k2lPFQ0XiU+B312aQaM+K5PUbJfLa+l2pLzfoDf+KHdIYoojBLJw+T9vY eeOfp0scH+AZFtQNCEL60F5AeQDHkapVBc6frDO8HKjQbna1gBN3EKC/0HSCgLrBegaf S+1TvJxL9yOdgFFDeYyqTqQ/IFlGyMFHwX3hriqSfmjxJzw/qH1XbZ97SZ01YtzsjOEw 9iVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PdwDeQPp; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d23si9592462pfr.274.2019.09.02.23.58.54; Mon, 02 Sep 2019 23:58:54 -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; dkim=pass header.i=@linaro.org header.s=google header.b=PdwDeQPp; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727497AbfICG6x (ORCPT + 28 others); Tue, 3 Sep 2019 02:58:53 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:35481 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726698AbfICG6w (ORCPT ); Tue, 3 Sep 2019 02:58:52 -0400 Received: by mail-pf1-f195.google.com with SMTP id 205so7723414pfw.2 for ; Mon, 02 Sep 2019 23:58:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=uoHHEgFr/r/SO8I5nMCow7X4j/JyWHdeMkJD+GMFPiE=; b=PdwDeQPp9bRkpVyUB8ZnEfizHOBfcvi+IexgeYYfm0/QujYrw17S3BbX9Astr2LmOX zwkG55XZnK9eNPTmFKugnMZRQotzoCWVW/1vV7dTgHOAKn7mRI//mOOmY75xG/yd1G74 7tJ8WqV0Qm29EjB6IVpudwwyrsqXRmoSAJHKGqWL2lb/Es9uH3EwFA1ft99E5+x6bXkF WfEt4tpdpy0HSafEI6XChqqIrkgf6i4nx+wPTt+WNJ0l26isH8+dgP/mZ5wr1RHRs9Dz TdI4Z3cuNxAQcAMWmuTOZIxy20vEqn+feb17ZRe4whsQKVXDRHYc8O28bz5bnVYEJDtd H05Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=uoHHEgFr/r/SO8I5nMCow7X4j/JyWHdeMkJD+GMFPiE=; b=NZhUje/1tA3uY4fooyUzWo5ikrumgul7RBByc2U2HHBTFgEa6LLG5+f36Zc3BAkZtD J2E8faTFb1veDL5zJ2o1gyhfc0XB2iCXqftGahasPLKOZTcMSvjWG4LSEWoUkL4dsAfI 87JSZn5435+WT5KfO07BUU95Ottn0RzL/4x1azBygfCMPNbP0csJHJs7YfFIj6r3xDS0 m4BobvEAGh2pIRlaTU9hAzFh2Qn4M4FRvDbgYrW9gnHYtPp+pqDLo/wyF04BZATT9pD5 0eNNDLddum/bL2UMKjypA418ViHAxP9oPaMIFbfs8H8LGYNgrAUaCqRDJv1pZq1zfTZ9 P18A== X-Gm-Message-State: APjAAAVB3CYU2pBafHiudtg4O2JNY3r/O36Y57n0L39rw+tzA7yTz3TP R4BCYijSu2LEUpb0X13j/H93uQ== X-Received: by 2002:a63:1f1f:: with SMTP id f31mr26065616pgf.353.1567493932285; Mon, 02 Sep 2019 23:58:52 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id b126sm36847718pfa.177.2019.09.02.23.58.48 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 02 Sep 2019 23:58:51 -0700 (PDT) From: Baolin Wang To: stable@vger.kernel.org, vyasevich@gmail.com, nhorman@tuxdriver.com, davem@davemloft.net Cc: hariprasad.kelam@gmail.com, linux-sctp@vger.kernel.org, netdev@vger.kernel.org, arnd@arndb.de, baolin.wang@linaro.org, orsonzhai@gmail.com, vincent.guittot@linaro.org, linux-kernel@vger.kernel.org Subject: [BACKPORT 4.14.y 4/8] net: sctp: fix warning "NULL check before some freeing functions is not needed" Date: Tue, 3 Sep 2019 14:58:16 +0800 Message-Id: <0e71732006c11f119826b3be9c1a9ccd102742d8.1567492316.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hariprasad Kelam 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 Acked-by: Marcelo Ricardo Leitner Acked-by: Neil Horman Signed-off-by: David S. Miller Signed-off-by: Baolin Wang --- net/sctp/sm_make_chunk.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) -- 1.7.9.5 diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c index f67df16..6dac492 100644 --- a/net/sctp/sm_make_chunk.c +++ b/net/sctp/sm_make_chunk.c @@ -2586,8 +2586,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; @@ -2652,8 +2651,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) { @@ -2667,8 +2665,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) { @@ -2684,8 +2681,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)