Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp2476278imd; Fri, 2 Nov 2018 12:04:43 -0700 (PDT) X-Google-Smtp-Source: AJdET5f3PbJBfcJBitWpzW+f1SUGW7uovP3s3AzvVGS9gJNPiMkOPwWUhhSY3Pi0ZOdxjNKc892p X-Received: by 2002:a63:d252:: with SMTP id t18mr11996585pgi.133.1541185483872; Fri, 02 Nov 2018 12:04:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541185483; cv=none; d=google.com; s=arc-20160816; b=YIRrvazAweTyTJGMFg4tIVNmoZBhVaMOtq0scMdFs/L3Iu8kPw/hrbXcC+o2vQO8Kd oB+mw9yAQRreV8nB0mUUN6UvBLXajR2t7bVleDZ1AYA9yuY5K86qW0Y3tmMscUuY/pYl IJpeGx49eFWznvraZX2njzveRN3OdvFc22mRX1lMZUr1pdScTksEpJ24f4URfytzmbcw Rje3adbqh/TnJWWF7LbR4q+U4YT3Z4+KTZ/yFmXIVIHtUVk0CYal9nDsBjMSMS1AcdxM Iiq6hT9VHRmlHCE0MJZ398Ehz7xWbmlegBrXDw/TohQ9yjPjqsSeiDs4g5t4RflNM31v rm+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=1nCTGD3/ycB40NvC9RWXGTBq/sHDtIfwiFo6ACeuhpw=; b=DuruU8DVQv+YNiE0PNQbdFmKH5PcCMfbR3sbLam/f4Qpw07XFcN4rMtqlT7tGfnzU5 b92oo9IMZhohtxmM2yatVVcNTenvI4vmmRY1l7rYGivG2Ln1u+I57ZnWgjPp0ERlOifG 5ApurFHjxrJfm1wjDvG+vtH6CRZUpUgR02JG+j9KomdaGoBRLcbggZn/wl5N1B+VHAUN V8MSzNbZ+rADmlpR0Mf6HdjcC2JA15WEPQTOKQSC2uItEBwwk0Cc+MLXRuiXf4TImsJM Fv5mYD7y/ljT6TojsVL0UnI/iELeDRm6nDc07xvv4JLPq87MyCGdQrT5Ee2JnY+xzunq glcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mhQ72hOt; 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 d34si4060982pgb.43.2018.11.02.12.04.28; Fri, 02 Nov 2018 12:04:43 -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=@kernel.org header.s=default header.b=mhQ72hOt; 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 S1730203AbeKCDxg (ORCPT + 99 others); Fri, 2 Nov 2018 23:53:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:49272 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729726AbeKCDxf (ORCPT ); Fri, 2 Nov 2018 23:53:35 -0400 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 760C92084A; Fri, 2 Nov 2018 18:45:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541184322; bh=f3PcTHy5gs5rHBpWEzIGHGAfeR/JrnW6Mr6rp8Tk7Xw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mhQ72hOtolw7zKViVJ37xVewovsxGIj1NPN17utVOmtP9R1eIu1x9lACZ5oTmSWIR wr3WKIGZAZZXZs0X87KeECgzNDKpe9hRcsEiyrGh4vVRppqlUHPBmx4yUOQUA2geOq dk7tAGIdfAsafYsuBsBEuxmsl3DmVHnNGWGngh98= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Karsten Graul , Ursula Braun , "David S. Miller" Subject: [PATCH 4.18 135/150] net/smc: fix smc_buf_unuse to use the lgr pointer Date: Fri, 2 Nov 2018 19:34:57 +0100 Message-Id: <20181102182912.056921139@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181102182902.250560510@linuxfoundation.org> References: <20181102182902.250560510@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Karsten Graul [ Upstream commit fb692ec4117f6fd25044cfb5720d6b79d400dc65 ] The pointer to the link group is unset in the smc connection structure right before the call to smc_buf_unuse. Provide the lgr pointer to smc_buf_unuse explicitly. And move the call to smc_lgr_schedule_free_work to the end of smc_conn_free. Fixes: a6920d1d130c ("net/smc: handle unregistered buffers") Signed-off-by: Karsten Graul Signed-off-by: Ursula Braun Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/smc/smc_core.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) --- a/net/smc/smc_core.c +++ b/net/smc/smc_core.c @@ -114,22 +114,17 @@ static void __smc_lgr_unregister_conn(st sock_put(&smc->sk); /* sock_hold in smc_lgr_register_conn() */ } -/* Unregister connection and trigger lgr freeing if applicable +/* Unregister connection from lgr */ static void smc_lgr_unregister_conn(struct smc_connection *conn) { struct smc_link_group *lgr = conn->lgr; - int reduced = 0; write_lock_bh(&lgr->conns_lock); if (conn->alert_token_local) { - reduced = 1; __smc_lgr_unregister_conn(conn); } write_unlock_bh(&lgr->conns_lock); - if (!reduced || lgr->conns_num) - return; - smc_lgr_schedule_free_work(lgr); } static void smc_lgr_free_work(struct work_struct *work) @@ -238,7 +233,8 @@ out: return rc; } -static void smc_buf_unuse(struct smc_connection *conn) +static void smc_buf_unuse(struct smc_connection *conn, + struct smc_link_group *lgr) { if (conn->sndbuf_desc) conn->sndbuf_desc->used = 0; @@ -248,8 +244,6 @@ static void smc_buf_unuse(struct smc_con conn->rmb_desc->used = 0; } else { /* buf registration failed, reuse not possible */ - struct smc_link_group *lgr = conn->lgr; - write_lock_bh(&lgr->rmbs_lock); list_del(&conn->rmb_desc->list); write_unlock_bh(&lgr->rmbs_lock); @@ -262,11 +256,16 @@ static void smc_buf_unuse(struct smc_con /* remove a finished connection from its link group */ void smc_conn_free(struct smc_connection *conn) { - if (!conn->lgr) + struct smc_link_group *lgr = conn->lgr; + + if (!lgr) return; smc_cdc_tx_dismiss_slots(conn); - smc_lgr_unregister_conn(conn); - smc_buf_unuse(conn); + smc_lgr_unregister_conn(conn); /* unsets conn->lgr */ + smc_buf_unuse(conn, lgr); /* allow buffer reuse */ + + if (!lgr->conns_num) + smc_lgr_schedule_free_work(lgr); } static void smc_link_clear(struct smc_link *lnk)