From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7C71EC433E7 for ; Thu, 8 Oct 2020 17:20:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2738322201 for ; Thu, 8 Oct 2020 17:20:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602177618; bh=qqJaQ8w9+/FSFtBNLOGYEQ7wz4IYZfeGaGac4ucM/GA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=nr6BYjjRc1/v90kolvqicuon2VIrnQBtB1c6Nk+npNf5VNkYQwcusBzRpkknm0Pen MpJEwgEEQwb1KpGf8J6Rlb++65oONjCDkGkJGTl5Fbp9kiBeOVGzxOztWfvyqsL6E3 8FmNhk/BLb922vJCVMUa/YKDT6gB6cVAnQpCRwuE= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731928AbgJHRUR (ORCPT ); Thu, 8 Oct 2020 13:20:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:39914 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728780AbgJHRUR (ORCPT ); Thu, 8 Oct 2020 13:20:17 -0400 Received: from localhost (unknown [213.57.247.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3E413204EF; Thu, 8 Oct 2020 17:20:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602177616; bh=qqJaQ8w9+/FSFtBNLOGYEQ7wz4IYZfeGaGac4ucM/GA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=V7Xmgrp5RI+cknUfCHil8Usd4zBVjfPjV1rt2Tlr4BVtZCM2VuLRGE1I+Xecomqoj bP8LYTXylGlFZp2ZdcuKZMVSaA1OMWsS0acb4Jc6VGA93XjPr0U2tOT7g74WmZvB0l QfVGV1A1O3YC1l60ZCwG5ka9VFOLPKrwkpT475jg= Date: Thu, 8 Oct 2020 20:20:11 +0300 From: Leon Romanovsky To: Dave Ertman Cc: alsa-devel@alsa-project.org, tiwai@suse.de, broonie@kernel.org, linux-rdma@vger.kernel.org, jgg@nvidia.com, dledford@redhat.com, netdev@vger.kernel.org, davem@davemloft.net, kuba@kernel.org, gregkh@linuxfoundation.org, ranjani.sridharan@linux.intel.com, pierre-louis.bossart@linux.intel.com, fred.oh@linux.intel.com, parav@mellanox.com, shiraz.saleem@intel.com, dan.j.williams@intel.com, kiran.patil@intel.com Subject: Re: [PATCH v2 1/6] Add ancillary bus support Message-ID: <20201008172011.GO13580@unreal> References: <20201005182446.977325-1-david.m.ertman@intel.com> <20201005182446.977325-2-david.m.ertman@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201005182446.977325-2-david.m.ertman@intel.com> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Mon, Oct 05, 2020 at 11:24:41AM -0700, Dave Ertman wrote: > Add support for the Ancillary Bus, ancillary_device and ancillary_driver. > It enables drivers to create an ancillary_device and bind an > ancillary_driver to it. > > The bus supports probe/remove shutdown and suspend/resume callbacks. > Each ancillary_device has a unique string based id; driver binds to > an ancillary_device based on this id through the bus. > > Co-developed-by: Kiran Patil > Signed-off-by: Kiran Patil > Co-developed-by: Ranjani Sridharan > Signed-off-by: Ranjani Sridharan > Co-developed-by: Fred Oh > Signed-off-by: Fred Oh > Reviewed-by: Pierre-Louis Bossart > Reviewed-by: Shiraz Saleem > Reviewed-by: Parav Pandit > Reviewed-by: Dan Williams > Signed-off-by: Dave Ertman > --- <...> > + > +static const struct ancillary_device_id *ancillary_match_id(const struct ancillary_device_id *id, > + const struct ancillary_device *ancildev) > +{ > + while (id->name[0]) { > + const char *p = strrchr(dev_name(&ancildev->dev), '.'); > + int match_size; > + > + if (!p) { > + id++; > + continue; > + } > + match_size = p - dev_name(&ancildev->dev); > + > + /* use dev_name(&ancildev->dev) prefix before last '.' char to match to */ > + if (!strncmp(dev_name(&ancildev->dev), id->name, match_size)) This check is wrong, it causes to wrong matching if strlen(id->name) > match_size In my case, the trigger was: [ 5.175848] ancillary:ancillary_match_id: dev mlx5_core.ib.0, id mlx5_core.ib_rep >From cf8f10af72f9e0d57c7ec077d59238cc12b0650f Mon Sep 17 00:00:00 2001 From: Leon Romanovsky Date: Thu, 8 Oct 2020 19:40:03 +0300 Subject: [PATCH] fixup! Fixes to ancillary bus Signed-off-by: Leon Romanovsky --- drivers/bus/ancillary.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/bus/ancillary.c b/drivers/bus/ancillary.c index 54858f744ef5..615ce40ef8e4 100644 --- a/drivers/bus/ancillary.c +++ b/drivers/bus/ancillary.c @@ -31,8 +31,10 @@ static const struct ancillary_device_id *ancillary_match_id(const struct ancilla match_size = p - dev_name(&ancildev->dev); /* use dev_name(&ancildev->dev) prefix before last '.' char to match to */ - if (!strncmp(dev_name(&ancildev->dev), id->name, match_size)) + if (match_size == strlen(id->name) && !strncmp(dev_name(&ancildev->dev), id->name, match_size)) { return id; + } + id++; } return NULL; -- 2.26.2 > + return id; > + id++; > + } > + return NULL; > +}