Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3428319imu; Sun, 11 Nov 2018 14:53:24 -0800 (PST) X-Google-Smtp-Source: AJdET5cZHXokuJ1s8qJ9f0tsbqRC+3n8ouHdanZEMj1vYPXEuRaX0CJ04VvdoH9YI30ueTuYi0Ny X-Received: by 2002:a63:d52:: with SMTP id 18-v6mr15535819pgn.107.1541976804538; Sun, 11 Nov 2018 14:53:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541976804; cv=none; d=google.com; s=arc-20160816; b=t0M5JFS9ErT0btmAkFbPpxR8VXwZBzmM1dsosmOEH5SyifTmS0u0qE9WcJqXNfn/Vx +an7I/32tuamifcpck/ruQWaRkXH0yf9guDRT2iha9YW9onMx+Zc8XpE9Hi/IgF3hETi GFSv9b/JDY+bxAaPrNxU7Cfr0S849dAk920NNb2rIE3kah/CQN/1QfFm63uX1zQ3ReRf asKmGaNdskvD5aBgH/eLfgx8075cEJ4x5V0w0WdYzZBi7RCrdKvuW6e9MLUcTHL+Zwsm mpVjMFrwtexBgxVWQCkwcrJ3WO37L5XOxky0O3DgSn21qKQ5Of6gsClPx/KQbmFa2zPa q5pg== 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=p3xqWiZOYm3sHo5LCsVHlVar2XyetMR+KID/YwMs0U8=; b=F7c9RIW7CBMiXeWK6ZlPwm8J750I+2JQxBfRrkdcvDlb5Dg4x3RklRAVCiXb2VDY/w YKDCgj3BZ4S6WySza7RFfNtwXUvkwK6iSn5C0xN7A72xsoVwkFwBxpXbWckH3cn7V0W7 SshBbta0swu0LQECZRGkN0TnpD7uDTAmqjIT7I+Hd2uhWKyULPX/QOZ/Gc3DI/5BB3w/ qI/0gP7u4JL3r9dnvXiiXJBhTTgcn12lHTxL5ddFEhZTFdGaLDH/l1p2xdIvSRqHJpqv iNGObKRn2CRS2vN/PSa+XG2z/Ixm7IaxZG7wA5o6XDZHRYooxYdubPa0Zf6rR0NzHd0V t96Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YdGzHIlo; 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 p189-v6si15887879pfg.235.2018.11.11.14.53.09; Sun, 11 Nov 2018 14:53:24 -0800 (PST) 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=YdGzHIlo; 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 S2391106AbeKLImz (ORCPT + 99 others); Mon, 12 Nov 2018 03:42:55 -0500 Received: from mail.kernel.org ([198.145.29.99]:54772 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389875AbeKLIXD (ORCPT ); Mon, 12 Nov 2018 03:23:03 -0500 Received: from localhost (unknown [206.108.79.134]) (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 47D3F21780; Sun, 11 Nov 2018 22:33:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975586; bh=Th8ZLcHp3w+rgtSGuK5nqQZtKv7Vt5eKaaVhPUokeRc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YdGzHIloscvYdH38KMT7hF2tmQDR5ZKs0OaYfZx4sXqrLawMNyELZBeK0tzF/obmw xM97vZnDlfk/wZwY/pjoCg8Cq+SRyHb95qbpNl6mYRmGggTw8nCEWi6slIfi9G9XvI RXxDsxGdcxlsxnwfnntPcdQ4MBQEangjlpxnFREc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Colin Ian King , Bjorn Andersson Subject: [PATCH 4.14 190/222] rpmsg: smd: fix memory leak on channel create Date: Sun, 11 Nov 2018 14:24:47 -0800 Message-Id: <20181111221703.929570948@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221647.665769131@linuxfoundation.org> References: <20181111221647.665769131@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.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Colin Ian King commit 940c620d6af8fca7d115de40f19870fba415efac upstream. Currently a failed allocation of channel->name leads to an immediate return without freeing channel. Fix this by setting ret to -ENOMEM and jumping to an exit path that kfree's channel. Detected by CoverityScan, CID#1473692 ("Resource Leak") Fixes: 53e2822e56c7 ("rpmsg: Introduce Qualcomm SMD backend") Cc: stable@vger.kernel.org Signed-off-by: Colin Ian King Signed-off-by: Bjorn Andersson Signed-off-by: Greg Kroah-Hartman --- drivers/rpmsg/qcom_smd.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) --- a/drivers/rpmsg/qcom_smd.c +++ b/drivers/rpmsg/qcom_smd.c @@ -1049,8 +1049,10 @@ static struct qcom_smd_channel *qcom_smd channel->edge = edge; channel->name = kstrdup(name, GFP_KERNEL); - if (!channel->name) - return ERR_PTR(-ENOMEM); + if (!channel->name) { + ret = -ENOMEM; + goto free_channel; + } mutex_init(&channel->tx_lock); spin_lock_init(&channel->recv_lock); @@ -1099,6 +1101,7 @@ static struct qcom_smd_channel *qcom_smd free_name_and_channel: kfree(channel->name); +free_channel: kfree(channel); return ERR_PTR(ret);