Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp3976241rwd; Tue, 23 May 2023 00:58:00 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5Tvr7m/3fBjnP+eM9m1a0y0ZcjldXZ508oeSvjtXoQQzAKzv+OyqGUm66VcCXoh7UZNWZK X-Received: by 2002:a05:6a21:6da5:b0:10b:78d6:a2c8 with SMTP id wl37-20020a056a216da500b0010b78d6a2c8mr6819397pzb.15.1684828679882; Tue, 23 May 2023 00:57:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684828679; cv=none; d=google.com; s=arc-20160816; b=QPo5eR3f0iwN07lgu25Jkrdz33miggaaXltfWCsR78yxFAuaONoiwIklJWFByAhpDp HmUOeNrmceUkf5xYd+nzbyBYKHJ2QR1fnsGpPbpo80PYTQjWUaN7LkgBKArJnYX4H4fJ F4MkDCAuCGNmOQvUjYRtVjLaW0iBRWu6j7JlBTZUalydH3aIkviRBM6Zc3+7OpNnlMii FU0IFEwkHKNwCkGKIW5l9cFO8reofOxsY+wVg13kofxKCEQTvw64H18gmgYCMweQhUzk MctcAH52i05r5ZMU7Fv/fhuRQgB798boJy8NRu3qyEHDpSFAUDjl9OvMVeyjml3AVgd4 0kag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=wjHzsw6r5GBiZYln6HcaZ/+TH4q9OK+QhfwKeMGSpWE=; b=cA9wKLNGGsJ61wN+3mM+vlfNA3BjzqcbecBlIXhBiiVjV8iS9v6qf+ZvbyTNVLMbM5 KxE8FoWOGVIYYpg+zRju8yhu5+HUp/KWvKYGn+CIFtIodLPL7v0adwQu0TpmVCfE6/iG BcJoGMNH48vKDeAWN/mwpMN3IUL9e4QcSSN3PUrKo4ZrhvHYoGbN9HcJEALoK+mD6w5A wUbooNGmPHtmxR2mgtRIVv4oCqKVrra1IL6b/k/hoQC9fWQG1TQvtWqgwN20xQDY3bzw oWNCxXpqeyt/vaFDJc0KMbY94i6te/nuq9fltiWChiDefBT4falQAceRKjI8EPO+z9K1 77cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=mXRFpVPR; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=fbSDasF5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c11-20020a056a00008b00b00643a730d50bsi1031548pfj.389.2023.05.23.00.57.47; Tue, 23 May 2023 00:57:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=mXRFpVPR; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=fbSDasF5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235897AbjEWH43 (ORCPT + 99 others); Tue, 23 May 2023 03:56:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236162AbjEWHzb (ORCPT ); Tue, 23 May 2023 03:55:31 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30C36E66 for ; Tue, 23 May 2023 00:55:08 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 2F89E20412; Tue, 23 May 2023 07:54:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1684828449; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wjHzsw6r5GBiZYln6HcaZ/+TH4q9OK+QhfwKeMGSpWE=; b=mXRFpVPRbXHozl7d1VkD3iVHJmQDfzORkMV/xuSFRbCEGbENe7osSTvazlzCP1ZtAnwZoB 8tShtavyMOM5UdrZvJMTphi40/hkFq40UBXWw2Tj/t0zWRjBwX+AS8+23r7k2Y9D3KSMzM awQOg5RO/I966kYcNPck0faRTzG1fKo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1684828449; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wjHzsw6r5GBiZYln6HcaZ/+TH4q9OK+QhfwKeMGSpWE=; b=fbSDasF5r7cHUc9ts/b0FjjsJCe/Typ/AGsvhMkrWS1mppHCQjO+NO6LRgZtDfbUgMwHXR xvebhLiQIytW8PDw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id EF11E13588; Tue, 23 May 2023 07:54:08 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id KG1oOSBxbGT4KgAAMHmgww (envelope-from ); Tue, 23 May 2023 07:54:08 +0000 From: Takashi Iwai To: alsa-devel@alsa-project.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH v2 22/37] ALSA: seq: Check validity before creating a port object Date: Tue, 23 May 2023 09:53:43 +0200 Message-Id: <20230523075358.9672-23-tiwai@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230523075358.9672-1-tiwai@suse.de> References: <20230523075358.9672-1-tiwai@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The client type and the port info validity check should be done before actually creating a port, instead of unnecessary create-and-scratch. Reviewed-by: Jaroslav Kysela Signed-off-by: Takashi Iwai --- sound/core/seq/seq_clientmgr.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c index 06743114cabf..2dac8c3355fd 100644 --- a/sound/core/seq/seq_clientmgr.c +++ b/sound/core/seq/seq_clientmgr.c @@ -1199,6 +1199,8 @@ static int snd_seq_ioctl_create_port(struct snd_seq_client *client, void *arg) /* it is not allowed to create the port for an another client */ if (info->addr.client != client->number) return -EPERM; + if (client->type == USER_CLIENT && info->kernel) + return -EINVAL; if (info->flags & SNDRV_SEQ_PORT_FLG_GIVEN_PORT) port_idx = info->addr.port; @@ -1208,12 +1210,6 @@ static int snd_seq_ioctl_create_port(struct snd_seq_client *client, void *arg) if (err < 0) return err; - if (client->type == USER_CLIENT && info->kernel) { - port_idx = port->addr.port; - snd_seq_port_unlock(port); - snd_seq_delete_port(client, port_idx); - return -EINVAL; - } if (client->type == KERNEL_CLIENT) { callback = info->kernel; if (callback) { -- 2.35.3