Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp1060176pxm; Wed, 23 Feb 2022 17:05:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJy67w/M4ikPn2TgVYhbSeD/GJbnKjZ66EzwwoRRa5DQIk8mTsAwdE2xpX+Dv1gWvUABjbbJ X-Received: by 2002:a17:902:a405:b0:14f:b5ee:cc59 with SMTP id p5-20020a170902a40500b0014fb5eecc59mr145694plq.95.1645664728462; Wed, 23 Feb 2022 17:05:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645664728; cv=none; d=google.com; s=arc-20160816; b=yonWCbPoHZ+RtF884EyB1hF4vh9JM3pFX/Z31dT1BcBxp2MJ/xDvCy4LW7xSgtut93 CNNSFPEl2WyTny2GpGE9fflPdwOQBDaLJgZThaL0+5ShQI5fe41P32+dFBFEY6CIoiwt B5MskBjhnlZjy3aCKP6nj0PVyvibitKReaNkBA795IGVYq/MYvNGcz6MO3aW6jljjk3R cUK0MOq0SinXA8AWNGNFEveknIvPg0cXnZVje5+stwddAoZKnfLJnNig3UBNGWdSXk5T PFh51tjSR7grNVvYcmPFLJuh3zpPUzW1a0pD7PJX1LvyALKFl6AneVb2fj43zOTAtWS7 35cg== 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=BfVj2+YbqU03eg9FI58FYBrziSuvlZ92uC4zdqn5CTE=; b=D5BUxEVI+IlyoFVx4IW2ApDMcZu6Dlf5vpgL9dm028j3qRwbwFXlHguFb8Xi3aiXGQ 4KSfCES+XPhrDzq+bsvG0CqShxgZfw307SFyPa1THDIFpcGjhx0g9lpw+I207DsYEjie dtjJkqKYmlbWbffdd/ZDW5nyjl0x6E1xEHhHrDXQD8grk3icK/ngkk+sGf9hHYCOeoGG wfuDsIyPUXsQQZc80E9hSDmBOMzNveR18kXuEpYF1/jO9tqmp2x4PmAxQHWwLze5+p1d fkkWUBvfHgYdBp1n7HUtbt3qk2BM4UP8ljwARn12AsGofzR9fP7OFwm3W4urye1v0lYH Lj3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=FeQ1H6XC; 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 y1si1026725pfw.231.2022.02.23.17.05.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Feb 2022 17:05:28 -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=FeQ1H6XC; 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 16B67E6C12; Wed, 23 Feb 2022 16:55:24 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244252AbiBWTOy (ORCPT + 99 others); Wed, 23 Feb 2022 14:14:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244226AbiBWTOt (ORCPT ); Wed, 23 Feb 2022 14:14:49 -0500 Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D7B0427ED for ; Wed, 23 Feb 2022 11:14:15 -0800 (PST) Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (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-0.canonical.com (Postfix) with ESMTPS id 62D873FCAE for ; Wed, 23 Feb 2022 19:14:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1645643654; bh=BfVj2+YbqU03eg9FI58FYBrziSuvlZ92uC4zdqn5CTE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=FeQ1H6XC8V3WXfVyoGk/lLB5m9ReO6lba9LpzkGjwMyOlfrfxfTPxGT6h22GmRV1V cBvHex5Xt+wQoQevbJ7KR7tVx09kn4w8R2HK+hV1XwBstjAW1iqImpQJPiCJj7q7a+ TsXb2crA3d1UD4+SVhgajTfgIBvPhri11Tp40JtxfQP8/PMdQrqZDqGK9yJyUmBG/k kKcEtvNSdy4GWwXADGBTPT3T29YjHVdQp8/a1PObHsqk6vaQVdT/MzyApG3BxWIc5i Vkn8bPEUc/A9s5PBB17Kz26qx8VEjMph34+oytqhnr2FrjRMJAYnF2Xa/XxLmU99Z5 AriCuRiH9kkTw== Received: by mail-wm1-f72.google.com with SMTP id z15-20020a1c4c0f000000b00380d331325aso1998245wmf.6 for ; Wed, 23 Feb 2022 11:14:14 -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=BfVj2+YbqU03eg9FI58FYBrziSuvlZ92uC4zdqn5CTE=; b=oQ7RmBJcrTUJGYOm/Rmk8P99XrKua6Az8cXN5OHqSpVxeXOH1j0naqRHfmyeVo8UJm mVVN8E8fD/3cDDjxEWfTgi8mRMl2VQpscSsGAdX7BzY/+9P+QrO/TmD98AJOCD/1VM65 OKKddxxm/yD5RTkmcUC+OEc3RD1h6+eTzayTVrHOW4xlZtAjYLTqHDvcKAThUsrpgOlo Im6vG286FgLNNQ9hsjJyo/jl9ZZI3E4KWDOzbmi3AfMqrPeA4eW10LvrdPR7m1f/IAws Wb4PgDLSm6jUrs6T0jbyoDNtGH+a1VwTiYPwVa4x/BKoUMrRKH6f+dD8Niwtx5mBRZhA KTew== X-Gm-Message-State: AOAM530ZFihKysLNXn9PbUb+4tInILEx0XvSdSBq2/tXZG4RHs+0d18p Cu2bmPrKZrakKozDQiWcw8EBZp6ddSrGsSjNplvsdm1EeTWzyXrP1ouaAgiNBi4UQATxUPPLeHu Lj3IFLb9lplrEAFnNVRmUzVrRgGjZQHxwk+saU4LIlQ== X-Received: by 2002:a17:907:271b:b0:6b8:7863:bf3e with SMTP id w27-20020a170907271b00b006b87863bf3emr962540ejk.188.1645643642492; Wed, 23 Feb 2022 11:14:02 -0800 (PST) X-Received: by 2002:a17:907:271b:b0:6b8:7863:bf3e with SMTP id w27-20020a170907271b00b006b87863bf3emr962519ejk.188.1645643642300; Wed, 23 Feb 2022 11:14:02 -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.14.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Feb 2022 11:14:01 -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 06/11] s390: cio: use helper for safer setting of driver_override Date: Wed, 23 Feb 2022 20:13:05 +0100 Message-Id: <20220223191310.347669-7-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/s390/cio/css.c | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c index fa8293335077..2ced49be1912 100644 --- a/drivers/s390/cio/css.c +++ b/drivers/s390/cio/css.c @@ -338,31 +338,15 @@ static ssize_t driver_override_store(struct device *dev, const char *buf, size_t count) { struct subchannel *sch = to_subchannel(dev); - char *driver_override, *old, *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 = sch->driver_override; - if (strlen(driver_override)) { - sch->driver_override = driver_override; - } else { - kfree(driver_override); - sch->driver_override = NULL; - } - device_unlock(dev); - - kfree(old); + ret = driver_set_override(dev, &dev->driver_override, buf); + if (ret) + return ret; return count; } -- 2.32.0