Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp2905292ybc; Mon, 18 Nov 2019 06:35:28 -0800 (PST) X-Google-Smtp-Source: APXvYqy9R42HrsyiQGHqh5FvFvtFcs/hBTEDGkGwv5GA4XLkfWNUR6jWPqhhqFpkOq1MrPFvmFnq X-Received: by 2002:a17:906:7708:: with SMTP id q8mr14276786ejm.33.1574087728794; Mon, 18 Nov 2019 06:35:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574087728; cv=none; d=google.com; s=arc-20160816; b=QTNxZmmziEgSTt0TAa+yef7p+O44NL6d83ZO3HvxMiKV9hoQ/vVQEzfDbvEI3Wx/UM XFOWNnKu1pnie2PBfZIXaBc4RxtFjhu2jB8/d75cCTOg6UTw8NKZ7b/k6tKdOQ3RbQ1c rp9bNdzb2V/s95XMaFKO2acQyFLgZHQOCZstI3q3o/eklgLl3Op9XL11QkgYuLbFxC1j KH8GNmD9uzbc2PGNRvkCxCl0KyqBkJwlaw6XODkwGmnwfp4ntGEZEf/bBB85jkWqbV1Z mWg572QCCLVmbd4BCUFADFXv641dKQTv+q++DHHkS6IXT1vMnfCx9R2a3IxSdBIfJgdx Vy4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=TG2g39EKBq+CMib7f8YSdExaoHY0ouhL+vmNC8C4Spk=; b=gnqicmGFTiXtBK5XoHYVgObrCOKzCyp6d7zVilDs0v93433DkvzKywxZxaKLAwD32k htUnEmP4Y2Bank+ani12U2M3CGVVdHqis4zjcI/qOCIbNCkOLlTx/juhMMG0iXusEbfB bspDxFUZWUNPuj4bzcjcP/TwTigtHmFm9OEA8j6jbfKqPOzR0pZ7OumoE9LlmxpzgSQq Mrj7PxkhQJF7VbknStSyibSszjwXnVjhmpkDZNrm/hOf75Cy8dYVeHku+5WXvrIE3Z0M kTGBd5BK70EokbHIf1uCH+mX3iOsdj8w+CLk6z2/k77hwgkw9DK21jbvMUv33EpODOoy eIeA== 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 k15si11455665ejq.153.2019.11.18.06.35.03; Mon, 18 Nov 2019 06:35:28 -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 S1726992AbfKROdz (ORCPT + 99 others); Mon, 18 Nov 2019 09:33:55 -0500 Received: from jabberwock.ucw.cz ([46.255.230.98]:57906 "EHLO jabberwock.ucw.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726668AbfKROdz (ORCPT ); Mon, 18 Nov 2019 09:33:55 -0500 Received: by jabberwock.ucw.cz (Postfix, from userid 1017) id 82E901C17F7; Mon, 18 Nov 2019 15:33:53 +0100 (CET) Date: Mon, 18 Nov 2019 15:33:52 +0100 From: Pavel Machek To: Takashi Iwai Cc: Pavel Machek , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, stable@vger.kernel.org, Dan Carpenter Subject: Re: [PATCH 4.19 062/125] ALSA: usb-audio: Fix possible NULL dereference at create_yamaha_midi_quirk() Message-ID: <20191118143352.GA22736@duo.ucw.cz> References: <20191111181438.945353076@linuxfoundation.org> <20191111181448.565879068@linuxfoundation.org> <20191113101954.GA32553@amd> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="VbJkn9YxBvnuCH5J" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --VbJkn9YxBvnuCH5J Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi! > > > Clearly code wants to allow at most one of them to be NULL. > > >=20 > > > > - 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; > > >=20 > > > Yet it will return here if it is. Correct check would be > > >=20 > > > + if (!(!injd || snd_usb_validate_midi_desc(injd)) || > > > + !(!outjd || snd_usb_validate_midi_desc(outjd))) > > >=20 > > > AFAICT. > >=20 > > Erm, right, but a better representation is: > >=20 > > if ((injd && !snd_usb_validate_midi_desc(injd)) || > > (outjd && !snd_usb_validate_midi_desc(injd))) >=20 > Of course, another typo: >=20 > if ((injd && !snd_usb_validate_midi_desc(injd)) || > (outjd && !snd_usb_validate_midi_desc(outjd))) Agreed, that is better. I was focusing on boolean algebra too much. Best regards, Pavel --=20 DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany --VbJkn9YxBvnuCH5J Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABECAB0WIQRPfPO7r0eAhk010v0w5/Bqldv68gUCXdKr0AAKCRAw5/Bqldv6 8gDNAJ4kJ+tyf4ZdegDGEovZiMQyBRmp/gCZAXSedY7aqWTdApLn62hibFLQeh8= =9w70 -----END PGP SIGNATURE----- --VbJkn9YxBvnuCH5J--