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 Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 309CAC433F5 for ; Wed, 16 Mar 2022 08:57:06 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id BFF8B4156D; Wed, 16 Mar 2022 08:57:05 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id jBOrZiFKXcWS; Wed, 16 Mar 2022 08:57:04 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp4.osuosl.org (Postfix) with ESMTPS id 4A5344167A; Wed, 16 Mar 2022 08:57:04 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 17DD7C0012; Wed, 16 Mar 2022 08:57:04 +0000 (UTC) Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 0E3B6C000B for ; Wed, 16 Mar 2022 08:57:03 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id EA5668430A for ; Wed, 16 Mar 2022 08:57:02 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp1.osuosl.org (amavisd-new); dkim=pass (1024-bit key) header.d=redhat.com Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id iMDkrZt6ys-m for ; Wed, 16 Mar 2022 08:57:02 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by smtp1.osuosl.org (Postfix) with ESMTPS id 34AE7842FA for ; Wed, 16 Mar 2022 08:57:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1647421021; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=0Bc153qdO6aJS+V+8boSatM96Pn9LsInVn8PpJNJpKY=; b=V60Ao4Zw1OA7tAOzdGW44leJ0jkElJhSPole8p+6UPMribGjSmwXawi+d7wL2Q1uaj/FON k2CwETmF1FBe7qqQ65ImSpIasQTWKeABDsfs/Z/Z9ZDbgpp3vQdsjJ7ohAKIiOP5I7+x9l Ax1/tYInHk81E+ISM4zKnhPSG9WCdaE= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-141-e1scfSYLMye054Ah5QPk8g-1; Wed, 16 Mar 2022 04:56:59 -0400 X-MC-Unique: e1scfSYLMye054Ah5QPk8g-1 Received: by mail-wr1-f70.google.com with SMTP id p9-20020adf9589000000b001e333885ac1so320978wrp.10 for ; Wed, 16 Mar 2022 01:56:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=0Bc153qdO6aJS+V+8boSatM96Pn9LsInVn8PpJNJpKY=; b=7qGAZZMC/4KGEoNIEFtmoQJ4+dBsgf29FSsxlSz/PFCoWM+DVaAoST8h5x7d5n+KUF HpCBFHDuNeKbHAPXeKte7Wo0LRctGeIFpE7w2RcRGKUH3xAdvy9nd4dtcY4TrDcEBzCg f/iToe+ij5z9T6ZtHrvu2/94IryRyJd2ehUSMskk0JFEpovRYO+Hk7wOHDfhtAB19kpk c7smDkbEvU0YKi6dgB7xTG6nhXwQDXhXiaK7I+4L803rZvAcJFj3XlRlXx2Y2bbTTnyi W8CZ2Zf2+IGmEpt+za3JSL0X9n76TBTSfkiJoNMve/j6VoUKPP+TzyWgXo8ZJI+tyJYb UnaA== X-Gm-Message-State: AOAM533IosMumIRgWyA/zuQy5kKw/Q3OyqsC1XDjmLXzfQhXIhL96m+l Ak7C01oFz15PYKgRnH4DnNwCi38t2NxnLj+y5UFIZFdXJd+DgtsRIFGKoiA83dYEoWD50uApXaL KrIxvji7ii35PU1ADpbf59Jd127ru32jV/ifoGciBOA== X-Received: by 2002:a5d:4d4b:0:b0:1f1:d99e:1122 with SMTP id a11-20020a5d4d4b000000b001f1d99e1122mr23570216wru.604.1647421018440; Wed, 16 Mar 2022 01:56:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxxg+HdKFc+OlgI5Uf6j74GkTyT+tlDfMeOChHK9/5Na0k8DDsBUyiZqTzroGOmIKGPRSv82g== X-Received: by 2002:a5d:4d4b:0:b0:1f1:d99e:1122 with SMTP id a11-20020a5d4d4b000000b001f1d99e1122mr23570190wru.604.1647421018228; Wed, 16 Mar 2022 01:56:58 -0700 (PDT) Received: from redhat.com ([2.53.2.35]) by smtp.gmail.com with ESMTPSA id p1-20020a5d59a1000000b00203d83b0ae4sm1136056wrr.109.2022.03.16.01.56.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Mar 2022 01:56:57 -0700 (PDT) Date: Wed, 16 Mar 2022 04:56:48 -0400 From: "Michael S. Tsirkin" To: Krzysztof Kozlowski Subject: Re: [PATCH v4 08/11] vdpa: Use helper for safer setting of driver_override Message-ID: <20220316045633-mutt-send-email-mst@kernel.org> References: <20220312132856.65163-1-krzysztof.kozlowski@canonical.com> <20220312132856.65163-9-krzysztof.kozlowski@canonical.com> MIME-Version: 1.0 In-Reply-To: <20220312132856.65163-9-krzysztof.kozlowski@canonical.com> Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Cc: linux-hyperv@vger.kernel.org, Stuart Yoder , "Rafael J. Wysocki" , linux-pci@vger.kernel.org, linux-remoteproc@vger.kernel.org, alsa-devel@alsa-project.org, Bjorn Andersson , Srinivas Kandagatla , Vineeth Vijayan , Alexander Gordeev , Fabio Estevam , linux-clk@vger.kernel.org, linux-s390@vger.kernel.org, Wei Liu , Stephen Hemminger , Abel Vesa , Dexuan Cui , Linus Torvalds , Andy Gross , NXP Linux Team , Heiko Carstens , Vasily Gorbik , linux-arm-msm@vger.kernel.org, Sascha Hauer , linux-spi@vger.kernel.org, Mark Brown , Rasmus Villemoes , Bjorn Helgaas , virtualization@lists.linux-foundation.org, linux-arm-kernel@lists.infradead.org, Laurentiu Tudor , Mathieu Poirier , Greg Kroah-Hartman , Haiyang Zhang , Peter Oberparleiter , linux-kernel@vger.kernel.org, Sven Schnelle , Shawn Guo X-BeenThere: virtualization@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux virtualization List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: virtualization-bounces@lists.linux-foundation.org Sender: "Virtualization" On Sat, Mar 12, 2022 at 02:28:53PM +0100, Krzysztof Kozlowski wrote: > Use a helper to set driver_override to reduce amount of duplicated code. > > Signed-off-by: Krzysztof Kozlowski Acked-by: Michael S. Tsirkin feel free to merge with the rest of the patchset. > --- > drivers/vdpa/vdpa.c | 29 ++++------------------------- > include/linux/vdpa.h | 4 +++- > 2 files changed, 7 insertions(+), 26 deletions(-) > > diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c > index 1ea525433a5c..2dabed1df35c 100644 > --- a/drivers/vdpa/vdpa.c > +++ b/drivers/vdpa/vdpa.c > @@ -77,32 +77,11 @@ static ssize_t driver_override_store(struct device *dev, > const char *buf, size_t count) > { > struct vdpa_device *vdev = dev_to_vdpa(dev); > - const char *driver_override, *old; > - char *cp; > + int ret; > > - /* We need to keep extra room for a newline */ > - if (count >= (PAGE_SIZE - 1)) > - return -EINVAL; > - > - driver_override = kstrndup(buf, count, GFP_KERNEL); > - if (!driver_override) > - return -ENOMEM; > - > - cp = strchr(driver_override, '\n'); > - if (cp) > - *cp = '\0'; > - > - device_lock(dev); > - old = vdev->driver_override; > - if (strlen(driver_override)) { > - vdev->driver_override = driver_override; > - } else { > - kfree(driver_override); > - vdev->driver_override = NULL; > - } > - device_unlock(dev); > - > - kfree(old); > + ret = driver_set_override(dev, &vdev->driver_override, buf, count); > + if (ret) > + return ret; > > return count; > } > diff --git a/include/linux/vdpa.h b/include/linux/vdpa.h > index 721089bb4c84..37117404660e 100644 > --- a/include/linux/vdpa.h > +++ b/include/linux/vdpa.h > @@ -64,7 +64,9 @@ struct vdpa_mgmt_dev; > * struct vdpa_device - representation of a vDPA device > * @dev: underlying device > * @dma_dev: the actual device that is performing DMA > - * @driver_override: driver name to force a match > + * @driver_override: driver name to force a match; do not set directly, > + * because core frees it; use driver_set_override() to > + * set or clear it. > * @config: the configuration ops for this device. > * @cf_mutex: Protects get and set access to configuration layout. > * @index: device index > -- > 2.32.0 _______________________________________________ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization