Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp130286ybc; Mon, 18 Nov 2019 21:50:16 -0800 (PST) X-Google-Smtp-Source: APXvYqyu1+3Fb8efMV9DTO8B0pVQDhPCVwg6dq0M6ISXqAKyEGriTSHfHfQenyx9wWYu+QjRxLY6 X-Received: by 2002:a17:906:4d58:: with SMTP id b24mr32037497ejv.277.1574142616687; Mon, 18 Nov 2019 21:50:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574142616; cv=none; d=google.com; s=arc-20160816; b=mamZjQRnqLApBMPm+Z4tGpJIDej3NShmFz+d6vePLwooNxUbbS629yOS6b7UTw6RzI nkkzGQIX1htnHrURAxJcXeirZfq+dvIvlE3+Z4F90E5sDHIEeYv2PAyrXilNPxlCIaqq wDdzcQ4y7PdzEmq/4MZteQhlbOXCLVqAW+fSNxJmTdErJ/eK8axgyz4EfDEeod89sGC6 CAh4z8k65itApV4euYDaOeigVJI8pJGEuShVR0z8hNDUVxkV1yQdc6q/yt8MYD26Pj/z c29RbQnnL5CngN01Tskkj2V0AKnx8NUWvGLbUWb31k3B/sh2PxRvti+2lvcXOiPZHr4L 6d4w== 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=4ZbXIg09dAmIje3cTIhuHmh9ehdq71TuTBUEGiiFn2k=; b=Lao21K5v1pWQQX5q6DuROAhcv6IGfOiIILXCqvmJhkXZ/c1AlcB1FvfPbGc5v9NxyR 03NLQOYHAtIFnX512To0/lwbvQJXeuQ0Pg2pp1vlYfDDRBTZ+yfq+l2hfWjLrRO4IrVa V3MVdddKETeweTNn5Cedw7ECB8xhH15l9VfwSaZOeV4gU1KgM11ryrZgKgZTwHianx9S x1/6JNC2J8/rVya8D0zu6U70h+i+ZLUuSGCQHpl7Ug3ELJfKR+t+KG4wt0qkUY/efwac 2JOyTcvwpdVghU/gLlOdmfH73KeCLEwIA1BOVZ0q9YJtFjcLFchUAO2TGBZIIATM4Hea NW4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2IkxXuGS; 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 va7si12563803ejb.18.2019.11.18.21.49.52; Mon, 18 Nov 2019 21:50:16 -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=2IkxXuGS; 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 S1730853AbfKSFqp (ORCPT + 99 others); Tue, 19 Nov 2019 00:46:45 -0500 Received: from mail.kernel.org ([198.145.29.99]:42824 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730839AbfKSFqk (ORCPT ); Tue, 19 Nov 2019 00:46:40 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.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 5BD6A2071B; Tue, 19 Nov 2019 05:46:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574142399; bh=ib4vu3ssWv+BcS446FDJwbNCxuG0zk6e/VuXGHHpq9s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2IkxXuGSiQ4PicaBuZmEwZoCd8zv5Qi1TL4UyHbAnP3vT2gMXJynurbpff9KWPl7Y WMfjqW/KPM/qEBIyDFt0ZnTkrfT3UYpKZcCKbR/8j6hd/nvzmyrpjaLwEcma1uCYwx T1dfzd4+rG6L8sMOuwopVNVough03EAk/r1jZAxI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Takashi Iwai , Sasha Levin Subject: [PATCH 4.14 041/239] ALSA: seq: Do error checks at creating system ports Date: Tue, 19 Nov 2019 06:17:21 +0100 Message-Id: <20191119051305.553503093@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191119051255.850204959@linuxfoundation.org> References: <20191119051255.850204959@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Takashi Iwai [ Upstream commit b8e131542b47b81236ecf6768c923128e1f5db6e ] snd_seq_system_client_init() doesn't check the errors returned from its port creations. Let's do it properly and handle the error paths. Signed-off-by: Takashi Iwai Signed-off-by: Sasha Levin --- sound/core/seq/seq_system.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/sound/core/seq/seq_system.c b/sound/core/seq/seq_system.c index 8ce1d0b40dce1..ce1f1e4727ab1 100644 --- a/sound/core/seq/seq_system.c +++ b/sound/core/seq/seq_system.c @@ -123,6 +123,7 @@ int __init snd_seq_system_client_init(void) { struct snd_seq_port_callback pcallbacks; struct snd_seq_port_info *port; + int err; port = kzalloc(sizeof(*port), GFP_KERNEL); if (!port) @@ -144,7 +145,10 @@ int __init snd_seq_system_client_init(void) port->flags = SNDRV_SEQ_PORT_FLG_GIVEN_PORT; port->addr.client = sysclient; port->addr.port = SNDRV_SEQ_PORT_SYSTEM_TIMER; - snd_seq_kernel_client_ctl(sysclient, SNDRV_SEQ_IOCTL_CREATE_PORT, port); + err = snd_seq_kernel_client_ctl(sysclient, SNDRV_SEQ_IOCTL_CREATE_PORT, + port); + if (err < 0) + goto error_port; /* register announcement port */ strcpy(port->name, "Announce"); @@ -154,16 +158,24 @@ int __init snd_seq_system_client_init(void) port->flags = SNDRV_SEQ_PORT_FLG_GIVEN_PORT; port->addr.client = sysclient; port->addr.port = SNDRV_SEQ_PORT_SYSTEM_ANNOUNCE; - snd_seq_kernel_client_ctl(sysclient, SNDRV_SEQ_IOCTL_CREATE_PORT, port); + err = snd_seq_kernel_client_ctl(sysclient, SNDRV_SEQ_IOCTL_CREATE_PORT, + port); + if (err < 0) + goto error_port; announce_port = port->addr.port; kfree(port); return 0; + + error_port: + snd_seq_system_client_done(); + kfree(port); + return err; } /* unregister our internal client */ -void __exit snd_seq_system_client_done(void) +void snd_seq_system_client_done(void) { int oldsysclient = sysclient; -- 2.20.1