Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1899742pxb; Fri, 5 Mar 2021 02:25:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJzhSA45LGdfCtYNm/XGf+QHRF+waz7/YzTQc6KTpOC9wFdA87AnhJRVtVJv1ZX/aYpDHK10 X-Received: by 2002:a17:906:c1d7:: with SMTP id bw23mr1597490ejb.554.1614939949239; Fri, 05 Mar 2021 02:25:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614939949; cv=none; d=google.com; s=arc-20160816; b=SmvTuIUrF8wZ6DPw9CynwjYn4tBFVwsFoOInN5FuNBCFmSaz0/S2zN/cv4Ai7p6Bpc hEGI7Mi7xvdASmXkrLut+wzEVSUGiQKEe9BfIltjn+4fTmc3YJeYkCSxeG7NhhRNGzAU gGrytSH3e1RG/3gqHvMAJvEcgT0Cb7ACtSs8EWHtoqd2+SxlrHc4bsSMwCqnaL1ydW1X M+CzlMrcXiKfAjf9qDT+Gf3mqCbHZ4xR9vRIlMLWKh9bYO5BMwoMa+frCS15oAnqG04a HELMAQ/7gh0s+R98xtzyXjmuSEEkHnQWvLSyu9R9vk/KqeY7M6Jh7UsEVQJTTqO/lIxu X3cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=oms5k2GecNDKeVMeIwpNOTm33olso5jl5qcGN9vIFVk=; b=PrG/qotifN1wouLK5bZyL77KkoUN9glNs8MHBTiGUtESiaXMWMBPhcWMBSQZwT0xbJ TBIXFJqpbz4+0TEKwP01lxMA/2K0T3qfQTDHT7QzR+KOozK2LrYbeAwwkQl/+rd/7DhL 5g2rK5gf7pOW7CYDw+NRQOzL3gr+HAfGTjZF2uuKdEFFClx6Y+kgZvTo9Wwcxh6PTswP KVFwkDFsI0ZwIwM8IzKoyxlI35DY3i2MhQt94ygr+sS4t4HNVR9Esg4AicjLehpfLICN mnIT9DdzM0mVUqJY29EYfISTU9ZrUm/2r+9DxCaDgmeHxOU4isnc4hVWnWBsJO4Pt6lk HHdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=rkq4psy9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id zd21si1127077ejb.634.2021.03.05.02.25.25; Fri, 05 Mar 2021 02:25:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=rkq4psy9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229615AbhCEKYd (ORCPT + 99 others); Fri, 5 Mar 2021 05:24:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229608AbhCEKYN (ORCPT ); Fri, 5 Mar 2021 05:24:13 -0500 Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A31D1C061574 for ; Fri, 5 Mar 2021 02:24:13 -0800 (PST) Received: by mail-pg1-x52e.google.com with SMTP id l2so1059124pgb.1 for ; Fri, 05 Mar 2021 02:24:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=oms5k2GecNDKeVMeIwpNOTm33olso5jl5qcGN9vIFVk=; b=rkq4psy9siFz3w2OMgw9jdTuaMXO3f5TojWSTgW2r8KBPulpjaFdMZr96JnPH06MBf pmMSeE++AxppcV04hZ36+pkWOE2r7dhPiT0z9LjUG2cXFb9GDporclI6GVYgwXq89WIJ NTNofa567uUPalRq0gEGxdi6Zag1EkCWwexvGQeqAFKpZoYP2cnv91W1Np9NYcvx0Dmm Lwxt/Qc6hVoTa4ikY+v/8EosIvGbJFzGP1srKfJ5p198f3X5mNeLtTWz6MOy8NYq3VV1 EYrKzPGR5qobp8vD8uo+nsby7XcNhon0yBt13HXfHcsfEHHLjb/Z5chdiTiPj37t6SqS qNww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=oms5k2GecNDKeVMeIwpNOTm33olso5jl5qcGN9vIFVk=; b=qJHZ3vHItZphuBPz63aS82/QqunpY+mZT6eMzg73HKEdLhTkLObDlaFPnqBiRYF6VH R95urRvjaZH+dgJk5FXf94gCHM88jACbyWh6M7UAqYNIXN9hJoM+fwkY2omw38GfNG3m oPorTv5AOijgqf3cJidhUeWX5X0UZ7XvI15DJVpPwbHxJG+Jqidmzu1eCRBYy9acWr2j Y6Bb/LWx8Ydf8I2kIO3MSxMx//0ptoiU4x3WI6zfNVLv+tUNh/x+PX10vrsOGihmR8/r zatTaSg8bxJ41nBjWxs3nB+eCAXclayLPI8hYqXrMa9TgN9F1Mq387WLuC6zLSrY1lV5 AvsQ== X-Gm-Message-State: AOAM531uOTMEwIo4ayiUJ/F25BEEnUn4Lh4G3Ba1seycVopFqYAS07mJ zCISg/OOEz8dgc2PCQO7xoM= X-Received: by 2002:a65:458b:: with SMTP id o11mr8009966pgq.416.1614939853197; Fri, 05 Mar 2021 02:24:13 -0800 (PST) Received: from localhost.localdomain ([45.135.186.129]) by smtp.gmail.com with ESMTPSA id w8sm2011574pgk.46.2021.03.05.02.24.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Mar 2021 02:24:12 -0800 (PST) From: Jia-Ju Bai To: gregkh@linuxfoundation.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, Jia-Ju Bai Subject: [PATCH] base: dd: fix error return code of driver_sysfs_add() Date: Fri, 5 Mar 2021 02:24:05 -0800 Message-Id: <20210305102405.14940-1-baijiaju1990@gmail.com> X-Mailer: git-send-email 2.17.1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When device_create_file() fails and returns a non-zero value, no error return code of driver_sysfs_add() is assigned. To fix this bug, ret is assigned with the return value of device_create_file(), and then ret is checked. Reported-by: TOTE Robot Signed-off-by: Jia-Ju Bai --- drivers/base/dd.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 9179825ff646..f94bbef95258 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -413,8 +413,11 @@ static int driver_sysfs_add(struct device *dev) if (ret) goto rm_dev; - if (!IS_ENABLED(CONFIG_DEV_COREDUMP) || !dev->driver->coredump || - !device_create_file(dev, &dev_attr_coredump)) + if (!IS_ENABLED(CONFIG_DEV_COREDUMP) || !dev->driver->coredump) + return 0; + + ret = device_create_file(dev, &dev_attr_coredump); + if (!ret) return 0; sysfs_remove_link(&dev->kobj, "driver"); -- 2.17.1