Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp1059365pxm; Wed, 23 Feb 2022 17:04:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJwFtww/0R7XbZ2oQSmjGc9BLBHF+r9n+rzNrgmlXCa+jIFcWO0cAGEoLIPUx+Big8x0SPk+ X-Received: by 2002:a17:902:da88:b0:150:f47:24ac with SMTP id j8-20020a170902da8800b001500f4724acmr143075plx.73.1645664674895; Wed, 23 Feb 2022 17:04:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645664674; cv=none; d=google.com; s=arc-20160816; b=jNexFQO5m3YBKeUoMyCFBVW/uX+jwW9S9z3Qx9lu2pYHyKMPuagUZ6qJznH4Bke7IS 9tjON2SufFWktHGqhBzsFo4UVR+itpEaE6J7W2JPtNJ4Bc1GPb/Moo2KSrJWrR0HACKo Y27y1cUjCqYF82hOSr6UuqJ6UhUJ5pWqE0CG1rCro97jg8QapComygXyoQvqEuZo4j+x 0whXvA8Ayi38WPmL7QV/s2ois9rms/Jxh9d8ObCge8Oydtf4HJCmAJXA6lg4vs6W1mYq Jma1NJkIHsfcFF8s0anQw+EM0tm+R0PQ2p503gQfFIoyH1Nffz7c75+92epITR1UXIic pIlw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=fyZde4QL+5WSjtUcZmZyQ9LOCmYULjkOm0dq/nBIuzo=; b=bxN1jH8V8YWP+olRmiD7FvWvpQ5sYd8C2VQ+/zsNp8PA4YyhoG0FI+gbOvuFGMITwi i47NH3b0JtgtGR8xnCj3/bGTbfDjx6bgms5OLrhfUysQMb6Y+hqtTp4m452LhlsDJRV9 9ZEF2f8hx08wK4kd3/o+bAEy/gNdNJ06KkXWg6lq5dp34hwayqhHrwJ2dn3/tOHFvbh7 MqVaJ7PO2jz+4AHRNsxzCwMjkaEvVbEZOrrS/tMyBuUUt6J0PJNsI2WYthu556u8J2H4 LbZsHy8fQkXk8SQ+waMbY3SpeZk8Lm3lwp8i0RdDYwokytMiEjET0KbvZZ0FXqZiKTLx lE+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=OBTY9jy0; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id u185si1079478pgd.16.2022.02.23.17.04.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Feb 2022 17:04:34 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=OBTY9jy0; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6FCC41451EF; Wed, 23 Feb 2022 16:54:43 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235378AbiBWTO7 (ORCPT + 99 others); Wed, 23 Feb 2022 14:14:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244199AbiBWTOv (ORCPT ); Wed, 23 Feb 2022 14:14:51 -0500 Received: from smtp-relay-internal-1.canonical.com (smtp-relay-internal-1.canonical.com [185.125.188.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5BDC403E8 for ; Wed, 23 Feb 2022 11:14:22 -0800 (PST) Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 9AFA23FCAC for ; Wed, 23 Feb 2022 19:14:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1645643659; bh=fyZde4QL+5WSjtUcZmZyQ9LOCmYULjkOm0dq/nBIuzo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OBTY9jy0CfhYh6XCstLMwvjLbIiZo+ZKMuaVOn+43X7uzty0dFGeeXK7+Hs3+NoMg 5tryJBh3qooZ/i0AmVobgqlgno1ulHD2T12tZs3Z3dmaAF0tTbznd43JUgpyoi34Hw CXahppu0zsvAy7Ud3Zy2RmbYGNmDx60eUFSrJWihOb7VueDDsvDKGmF5gpE1FjIbKK IwrY07htZ2QVQa7UWvbHvsiE0dkkaSrIXSX1ojijlkkaGxfKSVN2RIb7x1fsuiSvng gN+PMehG6PK4tU/IJJEKALcFmkpJY9xythFddyBBNvaJvUhZNS19z+1AdWfR3v6ER1 QRWIpMQV+Bibg== Received: by mail-ed1-f70.google.com with SMTP id l14-20020aa7cace000000b003f7f8e1cbbdso14056835edt.20 for ; Wed, 23 Feb 2022 11:14:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=fyZde4QL+5WSjtUcZmZyQ9LOCmYULjkOm0dq/nBIuzo=; b=iabLgaQPHz7tFDj6Rx1DcYzWHV760WAP30C0bOYJgvBX/93vHP2f+kLVNzWSLGQHpI M9ET7wM/l/957IiXRv68n4uctSuLEC4uVSHgFkOTnJ9jN8JxtsqTxgFDzdTU0r5XrCzo KW2lSUwk0zROTQhzINzerY+ex3s5AcPcP4zMpVvGnoRORDqUZ8RsiH+iSUwK2Mg7DeWM hr5cQ0L7Kq1sF/1v62qE9rnUXM1sIW8Vwy8WA/F3uGF6ddsQP+2WWEsIx0nqx6gRj8jP 6bawhsWwGLE9o61d399BV3UigoeR5pKsNaIZkQ7BDhYq/z0aEVs1AN2vHuyWynEmFKwW W3pA== X-Gm-Message-State: AOAM530g31IzUm0bCk+I/cF8VNo1sUyEsCqIaL5p6xNyEG4mHuVbeEZ1 nnPFkAUNNR+Pv5eJa5p+suwrZ1w8aXIH96GmndxTMN+58NvQeSky869rQdCZ/8MSqojgvtRQ3m9 ay5wFUU2IPYMhn4XJKJhZUjUaR+0kbE2r+b0QrJewXg== X-Received: by 2002:a17:906:a384:b0:6ce:c3f4:c59a with SMTP id k4-20020a170906a38400b006cec3f4c59amr870091ejz.580.1645643635870; Wed, 23 Feb 2022 11:13:55 -0800 (PST) X-Received: by 2002:a17:906:a384:b0:6ce:c3f4:c59a with SMTP id k4-20020a170906a38400b006cec3f4c59amr870048ejz.580.1645643635630; Wed, 23 Feb 2022 11:13:55 -0800 (PST) Received: from localhost.localdomain (xdsl-188-155-181-108.adslplus.ch. [188.155.181.108]) by smtp.gmail.com with ESMTPSA id q5sm212611ejc.115.2022.02.23.11.13.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Feb 2022 11:13:54 -0800 (PST) From: Krzysztof Kozlowski To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Stuart Yoder , Laurentiu Tudor , Abel Vesa , Shawn Guo , Sascha Hauer , Fabio Estevam , "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Wei Liu , Dexuan Cui , Bjorn Helgaas , Bjorn Andersson , Mathieu Poirier , Vineeth Vijayan , Peter Oberparleiter , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Andy Gross , Srinivas Kandagatla , Mark Brown , "Michael S. Tsirkin" , Jason Wang , linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, NXP Linux Team , linux-arm-kernel@lists.infradead.org, linux-hyperv@vger.kernel.org, linux-pci@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-s390@vger.kernel.org, linux-arm-msm@vger.kernel.org, alsa-devel@alsa-project.org, linux-spi@vger.kernel.org, virtualization@lists.linux-foundation.org, Linus Torvalds Cc: Rasmus Villemoes , Krzysztof Kozlowski Subject: [PATCH v2 03/11] fsl-mc: use helper for safer setting of driver_override Date: Wed, 23 Feb 2022 20:13:02 +0100 Message-Id: <20220223191310.347669-4-krzysztof.kozlowski@canonical.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220223191310.347669-1-krzysztof.kozlowski@canonical.com> References: <20220223191310.347669-1-krzysztof.kozlowski@canonical.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use a helper for seting driver_override to reduce amount of duplicated code. Signed-off-by: Krzysztof Kozlowski --- drivers/bus/fsl-mc/fsl-mc-bus.c | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/drivers/bus/fsl-mc/fsl-mc-bus.c b/drivers/bus/fsl-mc/fsl-mc-bus.c index 8fd4a356a86e..d93f4f680f82 100644 --- a/drivers/bus/fsl-mc/fsl-mc-bus.c +++ b/drivers/bus/fsl-mc/fsl-mc-bus.c @@ -166,8 +166,7 @@ static ssize_t driver_override_store(struct device *dev, const char *buf, size_t count) { struct fsl_mc_device *mc_dev = to_fsl_mc_device(dev); - char *driver_override, *old = mc_dev->driver_override; - char *cp; + int ret; if (WARN_ON(dev->bus != &fsl_mc_bus_type)) return -EINVAL; @@ -175,22 +174,9 @@ static ssize_t driver_override_store(struct device *dev, 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'; - - if (strlen(driver_override)) { - mc_dev->driver_override = driver_override; - } else { - kfree(driver_override); - mc_dev->driver_override = NULL; - } - - kfree(old); + ret = driver_set_override(dev, &mc_dev->driver_override, buf); + if (ret) + return ret; return count; } -- 2.32.0