From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751005AbeFAHjb (ORCPT ); Fri, 1 Jun 2018 03:39:31 -0400 Received: from mx2.suse.de ([195.135.220.15]:35259 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750729AbeFAHja (ORCPT ); Fri, 1 Jun 2018 03:39:30 -0400 Date: Fri, 01 Jun 2018 09:39:29 +0200 Message-ID: From: Takashi Iwai To: "Bo Chen" Cc: , , Subject: Re: [PATCH] ALSA: hda - Handle kzalloc() failure in snd_hda_attach_pcm_stream() In-Reply-To: <20180531223518.18675-1-chenbo@pdx.edu> References: <20180531223518.18675-1-chenbo@pdx.edu> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 01 Jun 2018 00:35:18 +0200, Bo Chen wrote: > > When 'kzalloc()' fails in 'snd_hda_attach_pcm_stream()', a new pcm instance is > created without setting its operators via 'snd_pcm_set_ops()'. Following > operations on the new pcm instance can trigger kernel null pointer dereferences > and cause kernel oops. > > This bug was found with my work on building a gray-box fault-injection tool for > linux-kernel-module binaries. A kernel null pointer dereference was confirmed > from line 'substream->ops->open()' in function 'snd_pcm_open_substream()' in > file 'sound/core/pcm_native.c'. > > This patch fixes the bug by calling 'snd_device_free()' in the error handling > path of 'kzalloc()', which removes the new pcm instance from the snd card before > returns with an error code. > > Signed-off-by: Bo Chen Applied now. Thanks. Takashi