From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-co1nam03on0118.outbound.protection.outlook.com ([104.47.40.118]:6048 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1032081AbeCAP2t (ORCPT ); Thu, 1 Mar 2018 10:28:49 -0500 From: Sasha Levin To: "stable@vger.kernel.org" , "stable-commits@vger.kernel.org" CC: Takashi Iwai , Sasha Levin Subject: [added to the 4.1 stable tree] ALSA: pcm: Add missing error checks in OSS emulation plugin builder Date: Thu, 1 Mar 2018 15:23:52 +0000 Message-ID: <20180301152116.1486-134-alexander.levin@microsoft.com> References: <20180301152116.1486-1-alexander.levin@microsoft.com> In-Reply-To: <20180301152116.1486-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Takashi Iwai This patch has been added to the 4.1 stable tree. If you have any objections, please let us know. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D [ Upstream commit 6708913750344a900f2e73bfe4a4d6dbbce4fe8d ] In the OSS emulation plugin builder where the frame size is parsed in the plugin chain, some places miss the possible errors returned from the plugin src_ or dst_frames callback. This patch papers over such places. Cc: Signed-off-by: Takashi Iwai Signed-off-by: Sasha Levin --- sound/core/oss/pcm_plugin.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/sound/core/oss/pcm_plugin.c b/sound/core/oss/pcm_plugin.c index 727ac44d39f4..a84a1d3d23e5 100644 --- a/sound/core/oss/pcm_plugin.c +++ b/sound/core/oss/pcm_plugin.c @@ -591,18 +591,26 @@ snd_pcm_sframes_t snd_pcm_plug_write_transfer(struct = snd_pcm_substream *plug, st snd_pcm_sframes_t frames =3D size; =20 plugin =3D snd_pcm_plug_first(plug); - while (plugin && frames > 0) { + while (plugin) { + if (frames <=3D 0) + return frames; if ((next =3D plugin->next) !=3D NULL) { snd_pcm_sframes_t frames1 =3D frames; - if (plugin->dst_frames) + if (plugin->dst_frames) { frames1 =3D plugin->dst_frames(plugin, frames); + if (frames1 <=3D 0) + return frames1; + } if ((err =3D next->client_channels(next, frames1, &dst_channels)) < 0) = { return err; } if (err !=3D frames1) { frames =3D err; - if (plugin->src_frames) + if (plugin->src_frames) { frames =3D plugin->src_frames(plugin, frames1); + if (frames <=3D 0) + return frames; + } } } else dst_channels =3D NULL; --=20 2.14.1