From patchwork Fri Jun 17 14:40:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 12885741 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7D4E3C433EF for ; Fri, 17 Jun 2022 14:41:54 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 257981F15; Fri, 17 Jun 2022 16:41:02 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 257981F15 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1655476912; bh=lFM+2XtqsneTZUw86cqqYScAS5RRp/8RcVfijttbRJA=; h=From:To:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=jZZdm80c9L3HjiR0eI+3q+GNyWL6Bn+JNWhegGXfRgKRI1a9eD3e5MUorg/sSwKsJ wNvhFXtnS7KeIDK2MmNhmDzMiBOXu0pPsLLCovAvU9jGMXWTJrDx4XQ5s1pfFFff17 X0I1EmGsXAuG2Xs4ybSfw4BQqthv63Tp40k6xHGI= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id A962AF8052D; Fri, 17 Jun 2022 16:41:01 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 1EA7EF80529; Fri, 17 Jun 2022 16:40:59 +0200 (CEST) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id C7157F804BC for ; Fri, 17 Jun 2022 16:40:55 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz C7157F804BC Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="2R1mtCzW"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="qFTENe8H" 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-out1.suse.de (Postfix) with ESMTPS id 7D6AB21D3B; Fri, 17 Jun 2022 14:40:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1655476855; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=vtZdOP7JpuBTxiFwOTKIu97MTlORDOzM3Lik64dB0KQ=; b=2R1mtCzWRjREaegiCzCJJDQvCPbt+JNF1n3VfzJ3K9RP/IuXbZ5AsDAYcU6WG4B9f5cSLw 6BoSp/ik+cbk4ik5sa6RtBJy9APrMgMdpxgfRBX7mL30vAoI9IFgFltU6ZZOuUQ9LKnHuf pxOiriPniqP2d0scgy59kKKlLxbco+A= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1655476855; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=vtZdOP7JpuBTxiFwOTKIu97MTlORDOzM3Lik64dB0KQ=; b=qFTENe8H4+8Z/0HkBFiwS3zLu55PlNAYiapbsJqDfGm07Vq4iQ4BNDqQ+/+GKK33cLIuAB 4YGwWxDJUeCMioBw== 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 6202B1348E; Fri, 17 Jun 2022 14:40:55 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id vV8vF3eSrGIYNQAAMHmgww (envelope-from ); Fri, 17 Jun 2022 14:40:55 +0000 From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 0/5] ALSA: rawmidi: Make code robust for external calls Date: Fri, 17 Jun 2022 16:40:46 +0200 Message-Id: <20220617144051.18985-1-tiwai@suse.de> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Hi, here is a small patch set for ALSA core rawmidi code to make the code a bit more robust, especially for the case where the exported functions get called from the external drivers. Currently most of those functions assume naively that they aren't called at a wrong timing. With the patch set, it tries to harden a bit not to hit serious breakage. Takashi === Takashi Iwai (5): ALSA: rawmidi: Make internal functions local static ALSA: rawmidi: Move lock to snd_rawmidi_substream ALSA: rawmidi: Take open_mutex around parameter changes ALSA: rawmidi: Check stream state at exported functions ALSA: rawmidi: Take buffer refcount while draining output include/sound/rawmidi.h | 6 +- sound/core/rawmidi.c | 274 +++++++++++++++++++++++++--------------- 2 files changed, 170 insertions(+), 110 deletions(-)