Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2833797pxv; Mon, 12 Jul 2021 03:05:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyeLSyvyx7sGHhMZ53mAJ9UNkVqx4Z7eia7uC9tYEMPJZ/laYK2BYqwhxBsj1zppmsSmmcv X-Received: by 2002:a05:6602:2204:: with SMTP id n4mr26471552ion.181.1626084334108; Mon, 12 Jul 2021 03:05:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626084334; cv=none; d=google.com; s=arc-20160816; b=0Y0W43ruXUfDJ/r48jMSVEid3eRRaaOxOW14mYEyOv1dvG/3/g32hxczpHcXREpUjc iFmEKxevX+cCqskI2Mkwe/ilCHS+DQZ3snnGEKg678AYPWwPKQ5gLOp2ll9Vl+DRnTdM MdhnQpzsoNpClrGsJ+ei/hx9uK/iXLWjcnBKJTfBuqT4NXq/CYQPiVvltKs+LVrnvWsb Ftz0mthFZ5sK7sRMGa45YKr/Xs9VrZ7Eeor/SzCK2qdWjoWEU2v7O30PrYIrrDnWPndi WSsZVXVozm5ASY6E5EGGvJgqxDZQSIYyOGjUrXPuWuxSNsm7nZTvi0e1JjwhhTFBEV7o uIlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=LYpJnYXtJFwobQZtd8sjIjKrZCmY5/vU9JDUj5vkCcI=; b=WXRRUp7NchaYU9yfqm5DU75z0xHTG8WmVTKNEvDIFSk1MfWLU7YZGE74P6GrgHEdJz YBY7uOTAb5ZCZAgpLz9ZHkaPZw1eawkYa5RlLWRBJD9AadW6WX+G8BzKjd+8iTzN8mm+ epLCyS+YNgTbXVlifIs70+9E08hL4ahVGKDb9TD9Z8Vzb0DAW5O5/HSAOTlsyi1dJOaO MRx/1/BMgAH0SGXFxI2UUeeyPD19sLcCARA7/JNCXW0VbUSTBc2xzkLpmbCgoZYBbZ9k zU1lKLW6nvUnvcdC5m+bIMYNDTGNEUa+eLqDhSOwms1Ea43Fnhx19c+Yc/qI7yhaPVw6 Fwsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VuiQ0Fgp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x9si17780117ill.103.2021.07.12.03.05.22; Mon, 12 Jul 2021 03:05:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VuiQ0Fgp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347077AbhGLHcG (ORCPT + 99 others); Mon, 12 Jul 2021 03:32:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:40076 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243088AbhGLHEb (ORCPT ); Mon, 12 Jul 2021 03:04:31 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B930E61152; Mon, 12 Jul 2021 07:01:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626073299; bh=xX8VyNOodZXaJbZ6Zo8s39DpvovzD6FKkh4MDY9d7wE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VuiQ0FgpLrQ50P6kOaP06xEpxDnilSnkTvWNlJlQK6Y58cln1oqXScy+VQkQOMJLn JPWEIyiwv10VmKuYEGjV6mfQDQFE5+eoLpHeukZkFjojENmHI8BsDYoTDbzCjFkV79 WqahMvKp+RCylsXYDzW0AN46BsgtUP3+nsFlpI8I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Shuah Khan , Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 5.12 194/700] media: Fix Media Controller API config checks Date: Mon, 12 Jul 2021 08:04:37 +0200 Message-Id: <20210712060954.302733879@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060924.797321836@linuxfoundation.org> References: <20210712060924.797321836@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Shuah Khan [ Upstream commit 50e7a31d30e8221632675abed3be306382324ca2 ] Smatch static checker warns that "mdev" can be null: sound/usb/media.c:287 snd_media_device_create() warn: 'mdev' can also be NULL If CONFIG_MEDIA_CONTROLLER is disabled, this file should not be included in the build. The below conditions in the sound/usb/Makefile are in place to ensure that media.c isn't included in the build. sound/usb/Makefile: snd-usb-audio-$(CONFIG_SND_USB_AUDIO_USE_MEDIA_CONTROLLER) += media.o select SND_USB_AUDIO_USE_MEDIA_CONTROLLER if MEDIA_CONTROLLER && (MEDIA_SUPPORT=y || MEDIA_SUPPORT=SND_USB_AUDIO) The following config check in include/media/media-dev-allocator.h is in place to enable the API only when CONFIG_MEDIA_CONTROLLER and CONFIG_USB are enabled. #if defined(CONFIG_MEDIA_CONTROLLER) && defined(CONFIG_USB) This check doesn't work as intended when CONFIG_USB=m. When CONFIG_USB=m, CONFIG_USB_MODULE is defined and CONFIG_USB is not. The above config check doesn't catch that CONFIG_USB is defined as a module and disables the API. This results in sound/usb enabling Media Controller specific ALSA driver code, while Media disables the Media Controller API. Fix the problem requires two changes: 1. Change the check to use IS_ENABLED to detect when CONFIG_USB is enabled as a module or static. Since CONFIG_MEDIA_CONTROLLER is a bool, leave the check unchanged to be consistent with drivers/media/Makefile. 2. Change the drivers/media/mc/Makefile to include mc-dev-allocator.o in mc-objs when CONFIG_USB is enabled. Link: https://lore.kernel.org/alsa-devel/YLeAvT+R22FQ%2FEyw@mwanda/ Reported-by: Dan Carpenter Signed-off-by: Shuah Khan Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/mc/Makefile | 2 +- include/media/media-dev-allocator.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/mc/Makefile b/drivers/media/mc/Makefile index 119037f0e686..2b7af42ba59c 100644 --- a/drivers/media/mc/Makefile +++ b/drivers/media/mc/Makefile @@ -3,7 +3,7 @@ mc-objs := mc-device.o mc-devnode.o mc-entity.o \ mc-request.o -ifeq ($(CONFIG_USB),y) +ifneq ($(CONFIG_USB),) mc-objs += mc-dev-allocator.o endif diff --git a/include/media/media-dev-allocator.h b/include/media/media-dev-allocator.h index b35ea6062596..2ab54d426c64 100644 --- a/include/media/media-dev-allocator.h +++ b/include/media/media-dev-allocator.h @@ -19,7 +19,7 @@ struct usb_device; -#if defined(CONFIG_MEDIA_CONTROLLER) && defined(CONFIG_USB) +#if defined(CONFIG_MEDIA_CONTROLLER) && IS_ENABLED(CONFIG_USB) /** * media_device_usb_allocate() - Allocate and return struct &media device * -- 2.30.2