Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp1766582ybc; Wed, 13 Nov 2019 04:06:12 -0800 (PST) X-Google-Smtp-Source: APXvYqwvliQN0KX3h+NTb3+hswG3JBspbPH7LLzvY3gyvBbybFkCRYXPb69uKnclt3Nd9WmB+Eow X-Received: by 2002:a50:fc1a:: with SMTP id i26mr3173951edr.9.1573646772645; Wed, 13 Nov 2019 04:06:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573646772; cv=none; d=google.com; s=arc-20160816; b=iTWsCWmTli0HV+sxJF8LlqcxNiblwNGAPNpANOEmvfKbQSfZXTUIc/nEa4nxZRvQuL egUADfnN0A33UoCNHbrR38vLEp+aWc7gZ4n/eAbydHRVQwZPLhyaDy9wpqPEmwqI4Hpj bRTj1qvjCZTLPzgreD2wVvK1FFzdEwB0Wdi+/WQjnRIpLspXtFETSQ5DUSC1AbWde37m TW8k/dk4Pn/9zxeZ4ZaUw8YK9OlgZMoqqWCWhC4sLjWzmu/vEPX3B1QnpyrN82DDUDEe KDVnMdgeEK+H+6+vhWH8f0YeC26+HYIzKynRwKpCa3fgKAY5TdvddhjwFmq9vl2rEV7S z9/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:subject:cc:to:from:message-id:date; bh=ebn8K7J+xozEJpSQIpFO/VdCMm28zDsUV3BxyJgvV8k=; b=MiI32PduQsm8S8CEZ1djWKOJicyqZXh3tQ1JNEANu1uPb90L1Y8Di64vHe4uRgcKXQ b+RIML5HjrhwxyqPK2hjQpyN2r0zX7t+62XEEbhJOddDJtOSl4svP9WIdFs+ew9WjaAB uh0Y8VO9I6VYfNYQEfU+AKnTCHH+nGu48sLRu+EjQfVvQDwfeNeOyrARjmHVhiTTnSQY zQBBsoT321X1OosIQrsb4Ujv+v87yo49z2BK2DsFKp+6YnRqnmP0ODtz/QjLX+aNWvZM D4xYqwCoviX3f5Vl+ANtAphXxo+/tD0lztrBkvZnDPJbPt7MAsuIzbuEW+EFnlH6aYSK 49Yw== ARC-Authentication-Results: i=1; mx.google.com; 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 63si1439354edp.302.2019.11.13.04.05.45; Wed, 13 Nov 2019 04:06:12 -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; 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 S1727557AbfKMKfS (ORCPT + 99 others); Wed, 13 Nov 2019 05:35:18 -0500 Received: from mx2.suse.de ([195.135.220.15]:54454 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726107AbfKMKfR (ORCPT ); Wed, 13 Nov 2019 05:35:17 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 7E3F6AC67; Wed, 13 Nov 2019 10:35:16 +0000 (UTC) Date: Wed, 13 Nov 2019 11:35:16 +0100 Message-ID: From: Takashi Iwai To: Pavel Machek Cc: Greg Kroah-Hartman , linux-kernel@vger.kernel.org, stable@vger.kernel.org, Dan Carpenter , Takashi Iwai Subject: Re: [PATCH 4.19 062/125] ALSA: usb-audio: Fix possible NULL dereference at create_yamaha_midi_quirk() In-Reply-To: <20191113101954.GA32553@amd> References: <20191111181438.945353076@linuxfoundation.org> <20191111181448.565879068@linuxfoundation.org> <20191113101954.GA32553@amd> 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 13 Nov 2019 11:19:54 +0100, Pavel Machek wrote: > > Hi! > > > From: Takashi Iwai > > > > commit 60849562a5db4a1eee2160167e4dce4590d3eafe upstream. > > > > The previous addition of descriptor validation may lead to a NULL > > dereference at create_yamaha_midi_quirk() when either injd or outjd is > > NULL. Add proper non-NULL checks. > > This is wrong. > > > @@ -259,8 +259,8 @@ static int create_yamaha_midi_quirk(stru > > NULL, USB_MS_MIDI_OUT_JACK); > > if (!injd && !outjd) > > return -ENODEV; > > Clearly code wants to allow at most one of them to be NULL. > > > - if (!snd_usb_validate_midi_desc(injd) || > > - !snd_usb_validate_midi_desc(outjd)) > > + if (!(injd && snd_usb_validate_midi_desc(injd)) || > > + !(outjd && snd_usb_validate_midi_desc(outjd))) > > return -ENODEV; > > Yet it will return here if it is. Correct check would be > > + if (!(!injd || snd_usb_validate_midi_desc(injd)) || > + !(!outjd || snd_usb_validate_midi_desc(outjd))) > > AFAICT. Erm, right, but a better representation is: if ((injd && !snd_usb_validate_midi_desc(injd)) || (outjd && !snd_usb_validate_midi_desc(injd))) thanks, Takashi