Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp1072705ybm; Tue, 21 May 2019 08:14:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqyGYiA/df9tM095OwZ7Y5OPKkX/5zEQzZEHOgoQppjYvbVssg3onMzCCoKC1AGFLJJ5vcvz X-Received: by 2002:a63:10d:: with SMTP id 13mr56402122pgb.176.1558451660346; Tue, 21 May 2019 08:14:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558451660; cv=none; d=google.com; s=arc-20160816; b=NVMImxMqspqLsYUpCyIn53o401QR+be26uDvt5KJi8FQz7Da9wzV52oPwMoIf1SF8W 8D2wcfj3YLpQ0ow0R4OH2fZPd+kQcO7WyJNE1zPbaUw9f8a5Q27PL1U+x3Te1Nbep+lv vIiuJEeoKbRFKCrk9nqrPq3ewMm+/AplPjfYlIR8mWd/OgTVTqGOsux9DR/fmVsPRDwZ 7e6CptT53kb2+irWCgXdqUpHFHFswhJ6X9VjnYpO/TG9WSvChchV4tw1GmmyrGOsYq/w kAQD+flZxr9NXdclwA80FSqR+OBIk0cJ1loU9AGbpNBhWurcIilDJzWFZU8/acWRpokS I7+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=uenEQC1L432pTxYU+zQh/Ux7TUPsPQOR7Iodn9EUbh8=; b=EJOWcOansAD5CCeYQgn+v7gunig/uL+adc8LXesVTjSgIPjmq0fkLVq8TW7D0uarno M5nukbhStiPAxIZpRn6Z/6hjCLMPmO9PQ+FnDufeM/UsP65wCvE0FVkcW+lFHLaSfSPk 5oypC5+2M0xzrXdNUosRN3xFdLzcGzMf0Obu2oxvLfyBS8aZBFs1WLT6Y6cWKpRZXG7T aDXfxDfjICWq80iC7qvKRv2tB3P7wZV5baB/HULmGx+HFl4B+Zz13ruJ095Dci0fEI0w 4T2jAHRGS9lZpUDvHX9j9FlqO5Ha92MzTVi5nZKzbq7YhdOkj7IsLzkdGFp9S2K6hQPy cqqw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v14si22863299pfa.252.2019.05.21.08.14.04; Tue, 21 May 2019 08:14:20 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728114AbfEUMzx (ORCPT + 99 others); Tue, 21 May 2019 08:55:53 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:47192 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726692AbfEUMzx (ORCPT ); Tue, 21 May 2019 08:55:53 -0400 Received: from localhost (unknown [IPv6:2a01:e0a:2c:6930:5cf4:84a1:2763:fe0d]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: bbrezillon) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id 1C7C1283ECE; Tue, 21 May 2019 13:55:51 +0100 (BST) Date: Tue, 21 May 2019 14:55:48 +0200 From: Boris Brezillon To: Helen Koike Cc: linux-media@vger.kernel.org, hverkuil-cisco@xs4all.nl, kernel@collabora.com, ezequiel.garcia@collabora.com, andrealmeid@collabora.com, Mauro Carvalho Chehab , linux-kernel@vger.kernel.org Subject: Re: [PATCH] media: vimc: fix component match compare Message-ID: <20190521145548.27844fa6@collabora.com> In-Reply-To: <20190517172011.13257-1-helen.koike@collabora.com> References: <20190517172011.13257-1-helen.koike@collabora.com> Organization: Collabora X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 17 May 2019 14:20:11 -0300 Helen Koike wrote: > If the system has other devices being registered in the component > framework, the compare function will be called with a device that > doesn't belong to vimc. > This device is not necessarily a platform_device, nor have a > platform_data (which causes a NULL pointer dereference error) and if it > does have a pdata, it is not necessarily type of struct vimc_platform_data. > So casting to any of these types is wrong. > > Instead of expecting a given pdev with a given pdata, just expect for > the device it self. vimc-core is the one who creates them, we know in > advance exactly which object to expect in the match. > > Fixes: 4a29b7090749 ("[media] vimc: Subdevices as modules") Oh, and you forgot to add Cc: > Signed-off-by: Helen Koike > > --- > > drivers/media/platform/vimc/vimc-core.c | 7 ++----- > 1 file changed, 2 insertions(+), 5 deletions(-) > > diff --git a/drivers/media/platform/vimc/vimc-core.c b/drivers/media/platform/vimc/vimc-core.c > index 3aa62d7e3d0e..23992affd01f 100644 > --- a/drivers/media/platform/vimc/vimc-core.c > +++ b/drivers/media/platform/vimc/vimc-core.c > @@ -244,10 +244,7 @@ static void vimc_comp_unbind(struct device *master) > > static int vimc_comp_compare(struct device *comp, void *data) > { > - const struct platform_device *pdev = to_platform_device(comp); > - const char *name = data; > - > - return !strcmp(pdev->dev.platform_data, name); > + return comp == data; > } > > static struct component_match *vimc_add_subdevs(struct vimc_device *vimc) > @@ -277,7 +274,7 @@ static struct component_match *vimc_add_subdevs(struct vimc_device *vimc) > } > > component_match_add(&vimc->pdev.dev, &match, vimc_comp_compare, > - (void *)vimc->pipe_cfg->ents[i].name); > + &vimc->subdevs[i]->dev); > } > > return match;