From patchwork Wed Jul 25 21:08:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Pallardy X-Patchwork-Id: 142912 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp1274463ljj; Wed, 25 Jul 2018 14:08:52 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfYoqXRcaGZAdqAGmuYXL2PuEmkAjccvkCzywEeNT06D5ksDreu1hQShXTeYhtM2vuxmgXq X-Received: by 2002:a17:902:d70d:: with SMTP id w13-v6mr22568889ply.40.1532552932551; Wed, 25 Jul 2018 14:08:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532552932; cv=none; d=google.com; s=arc-20160816; b=jT1562KqWtldJAvT1uGnRS7EIviZECtXLBr55r6lEtDsiQ0HTEyKPw+uEeSf9f/w4Z OGeySYzLXqGh9NXlYj2jY/YVLM25RoinbwKFP5AaKNIE+fsrM7oedmkR6zAf+4DBQBTP HtH6IEIrwlB7Rtfd77sp6Uh+b+lLYeEg9cXTARpdcKItiDBzVite+FOUFU/e4tJhxXuR z22PxTitYutA1DcUDKU5PAPjACbuyZezdyovr+0eUdiiSueBKr0b/6vfgD7MMP6YfsIV KGVomhpzL/o0/vB7/gcsRtRmWFt/9Ke0a1hkF2gWhLJvObmoCEoPGsEUI3g3gK4yuvSj bxoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:arc-authentication-results; bh=0nQKvqmrzrNSrKeqovyo+7xNwm7aArrVFpEkcR7zZkI=; b=OYlWGu6LqgguM71q9GcOOPASXNL/SfuYZffxVlWGpPDUu8S7c99bZqAkzs1Ln46cqw 6fGamd3y/1xRVBO0SqyhlZXtYvoL+rHKGee1dYIBjfsPM1VNu/rHPkrFwrf37qa8V7Cq uVcDAIFF6JE+bWoaHCiXKGipq8ivPVMMpXIwsuzMbgk5Pv/uYfyLjZpVCEJGk09DrLP/ IIigKRdqa9Su7l7sjbooN850tNXISlrNwMpcz3IzmO1NTPrhFYY1HEmFEIko4ySi3g59 36UhsgrrsQn7YvxKpE6KlxgU8o+hK2gl3y0HXy5vzh2lgM0u8i5dJfk+b/CfzBpK6JMz blIA== 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 ce14-v6si14352851plb.391.2018.07.25.14.08.52; Wed, 25 Jul 2018 14:08:52 -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 S1731382AbeGYWWS (ORCPT + 31 others); Wed, 25 Jul 2018 18:22:18 -0400 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:54085 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731150AbeGYWWR (ORCPT ); Wed, 25 Jul 2018 18:22:17 -0400 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx08-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w6PL4VJi003395; Wed, 25 Jul 2018 23:08:46 +0200 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2kbuqdw99k-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Wed, 25 Jul 2018 23:08:46 +0200 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 2480331; Wed, 25 Jul 2018 21:08:46 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag7node2.st.com [10.75.127.20]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 09E4AB445; Wed, 25 Jul 2018 21:08:46 +0000 (GMT) Received: from localhost (10.75.127.44) by SFHDAG7NODE2.st.com (10.75.127.20) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Wed, 25 Jul 2018 23:08:45 +0200 From: Loic Pallardy To: , CC: , , , , Loic Pallardy Subject: [PATCH 1/1] rpmsg: virtio_rpmsg_bus: Fix rpmsg_create_channel memory leak Date: Wed, 25 Jul 2018 23:08:36 +0200 Message-ID: <1532552916-30111-1-git-send-email-loic.pallardy@st.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Originating-IP: [10.75.127.44] X-ClientProxiedBy: SFHDAG5NODE3.st.com (10.75.127.15) To SFHDAG7NODE2.st.com (10.75.127.20) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-07-25_04:, , signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In case of rpmsg_register_device() failure, vch previously allocated must be free. fixes: 6eed598a0491 ("rpmsg: Split off generic tail of create_channel()") Signed-off-by: Loic Pallardy --- drivers/rpmsg/virtio_rpmsg_bus.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) -- 1.9.1 diff --git a/drivers/rpmsg/virtio_rpmsg_bus.c b/drivers/rpmsg/virtio_rpmsg_bus.c index 664f957..10f927e 100644 --- a/drivers/rpmsg/virtio_rpmsg_bus.c +++ b/drivers/rpmsg/virtio_rpmsg_bus.c @@ -431,8 +431,10 @@ static struct rpmsg_device *rpmsg_create_channel(struct virtproc_info *vrp, rpdev->dev.parent = &vrp->vdev->dev; rpdev->dev.release = virtio_rpmsg_release_device; ret = rpmsg_register_device(rpdev); - if (ret) + if (ret) { + kfree(vch); return NULL; + } return rpdev; }