Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp1036584rdg; Wed, 11 Oct 2023 12:22:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEX6T2KZWUF8Q5xQZ+Pm2Y1zsFMaGoR2zsVbuncQGsyQ3X6NhT+P5adCh8wYma54lvVdCTM X-Received: by 2002:a17:902:e881:b0:1c0:ecbb:182f with SMTP id w1-20020a170902e88100b001c0ecbb182fmr27106055plg.5.1697052129655; Wed, 11 Oct 2023 12:22:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697052129; cv=none; d=google.com; s=arc-20160816; b=mB7XMCOfHP5lc41wD7JjMXUiX21WhDFbVmEmY1KSeDNqeCS4WBcrg1armNhj6ZL/Ab 2TlrrJRbc+kiUEcbGOxtMqCF3u0ftMZXjZuD0YQnXPIbjGkWYRn+tMNIq/VdHIlvoyRL b5BmJg45vcm+NO7SzriMjd6WuW3nuhHYbnjhEVFnsfLg/xj4aLpO5DjUPXzagOTW3Dif ydjpCVnQCWymMVxPNPheRKd5yG9yqwU6VGqPENlcQk0Qle39qNn2FOGyBKfbDD7Y5ORk 5gjsebFw2MuKBe4EwB3VnLwUh5+08Uvc8Q9JDYYYW4m9Wo/hb3QIRfF1HnNHe9g9Fq+K vdGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:to:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=h+v1IOG/jmNDJTRhW9IuaIpAohQ4Dp4Gm4L7ijlhMLQ=; fh=6qoU4XI0b/xTmeTZ6j/lc1nY7xYXQL9c9zlG2PextdI=; b=A1SwodND4UI0OdGv7M6T6vsfC1k7ZgZvYobGgFLI0HSZ2xk5bk7Gq2XjJJ/m/veqYt sYyh9s+UTgTMT1ikdQCGLQ1mdYufrKSfcjJyk0CdAgO8of9g9iEq0sN1vv2eUYvImVgc 2xLfRrMwl7KV8DHzHod2ZUqHtifd/y3MPHUSWVb2rM5FH9YERdtXphjyRQOxCgMLkwmV jjxx0OAaZ+/N6ZX7zzOBK7jXZd4oGEkVs1bV1EHABEyKD4lmqH5D6NZvCzkrnIW6TESv 3iEvcK5fmcUhqWo/P/vuT9LEPkxpQGagnOaTf3Na45Ay+LapHCURKfFU9qI9kjs6vIXJ SDqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=ZAVIne1q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id 10-20020a170902c20a00b001c6036c5b74si346983pll.245.2023.10.11.12.22.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 12:22:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=ZAVIne1q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 8F4D2818FBF0; Wed, 11 Oct 2023 12:22:06 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346999AbjJKTV6 (ORCPT + 99 others); Wed, 11 Oct 2023 15:21:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347010AbjJKTV5 (ORCPT ); Wed, 11 Oct 2023 15:21:57 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B29BEA4 for ; Wed, 11 Oct 2023 12:21:56 -0700 (PDT) Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 39BJHVFe023054; Wed, 11 Oct 2023 19:21:49 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : mime-version : subject : to : references : from : in-reply-to : content-type : content-transfer-encoding; s=pp1; bh=h+v1IOG/jmNDJTRhW9IuaIpAohQ4Dp4Gm4L7ijlhMLQ=; b=ZAVIne1qZ+e/BJWw3nQbQntJdSvHIqv8FsfTOZKEpWPJWycCaukcZEPfpvLJxvrUbDKc f66Q7wzKU4Ump9IGeuVXKLTOQ6LL0r9pDu/Cp1apsA5qbe4BjNGFOx1AdSNQP176afU0 1Rr8k+w4OGwXRnr3+cC3nBXCTpJXduexv/99lbWWjqMpuQFyf6+p2jDOIawNd1IZlE59 9h5andyJSpX2GDYbzmRDmPj7nGQLc3uUboNeqQkYdIntlv+kTwEpFkb/EzPSFLORYwFJ S4XPbCTcMFGFQ+qyNriI1FLZMIGDmz01mGAC2uS4TanZ7hQSHSezztvV2/xC2e40sGpP KA== Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3tp1qx07nx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 11 Oct 2023 19:21:49 +0000 Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 39BI4bYK024465; Wed, 11 Oct 2023 19:21:48 GMT Received: from smtprelay05.dal12v.mail.ibm.com ([172.16.1.7]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 3tkhnstqgh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 11 Oct 2023 19:21:48 +0000 Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay05.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 39BJLmnE24773120 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 11 Oct 2023 19:21:48 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3FB0158055; Wed, 11 Oct 2023 19:21:48 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 161CB58043; Wed, 11 Oct 2023 19:21:48 +0000 (GMT) Received: from [9.61.37.205] (unknown [9.61.37.205]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 11 Oct 2023 19:21:48 +0000 (GMT) Message-ID: <8a81172f-e920-88d2-41ec-f9ce90a0afc1@linux.ibm.com> Date: Wed, 11 Oct 2023 14:21:47 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [PATCH v3 2/2] fsi: sbefifo: Handle pending write command Content-Language: en-US To: Ninad Palsule , jk@ozlabs.org, joel@jms.id.au, alistair@popple.id.au, linux-fsi@lists.ozlabs.org, linux-kernel@vger.kernel.org References: <20231010204348.2600242-1-ninad@linux.ibm.com> <20231010204348.2600242-3-ninad@linux.ibm.com> From: Eddie James In-Reply-To: <20231010204348.2600242-3-ninad@linux.ibm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: FOHvAE02bLqYh64MaygYn6MUziDIyB7G X-Proofpoint-GUID: FOHvAE02bLqYh64MaygYn6MUziDIyB7G X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-11_14,2023-10-11_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 phishscore=0 mlxscore=0 suspectscore=0 impostorscore=0 adultscore=0 spamscore=0 mlxlogscore=999 malwarescore=0 bulkscore=0 lowpriorityscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310110171 X-Spam-Status: No, score=-0.5 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 11 Oct 2023 12:22:07 -0700 (PDT) On 10/10/23 15:43, Ninad Palsule wrote: > If previous write command is still pending then free it first. > > As per the current kernel driver design, write operation prepares a > buffer for FSI write, the actual FSI write is performed on next read > operation. There is a possibility of memory leak if buggy application > sends two back to back writes or two parallel writes. Reviewed-by: Eddie James > > Signed-off-by: Ninad Palsule > --- > v3: > - Incorporated review comments by Eddie. > --- > drivers/fsi/fsi-sbefifo.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/drivers/fsi/fsi-sbefifo.c b/drivers/fsi/fsi-sbefifo.c > index a95b32461f8f3..1cc88a78e588a 100644 > --- a/drivers/fsi/fsi-sbefifo.c > +++ b/drivers/fsi/fsi-sbefifo.c > @@ -877,6 +877,13 @@ static ssize_t sbefifo_user_write(struct file *file, const char __user *buf, > > mutex_lock(&user->file_lock); > > + /* If previous write command is still pending then free it. It is safe > + * to do that because read cannot be in progress since we hold the > + * lock. > + */ > + if (user->pending_cmd) > + sbefifo_release_command(user); > + > /* Can we use the pre-allocate buffer ? If not, allocate */ > if (len <= PAGE_SIZE) > user->pending_cmd = user->cmd_page;