Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2202866pxb; Fri, 5 Mar 2021 09:32:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJzwKQJykGFiZd1sxyQ/GV7x5cZcBJ5BmHJAzT0uvMnbhsPE2dBYAF38NFsvhcTIxgsXYQyp X-Received: by 2002:a05:6402:10c6:: with SMTP id p6mr2627091edu.241.1614965569113; Fri, 05 Mar 2021 09:32:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614965569; cv=none; d=google.com; s=arc-20160816; b=cKw/TiUa/manDlAFrLyHy5vAM62/GrPrzLc51ZTlcyTm9GQ9tx7fAI+lZgMWvyD118 VTj64D2aGZGDgvKyIQ4Aki4ZCxGu1PO9TE+oXsRn+4s3Aii/ABGqKHZYP3SQU9ZK+iyj 8qBPPzPLg2EZU+I5sJSrm5PgFzj9SZUFyBYlBX9XuZrggMRDOGIeZOGO6RR2zHTkP9sL 0zDgb/o+tWi/ZmfLt/djE5fycGj2UluzkzRut9Ulh3GoOXSoH8w20vldV2YyPXlQol84 0FCT3RzDyyKQd50Gb8e2LgenQrxlWeEL2c6IeM+oXtwzXpN5AC3xHsQCOHSR1W46bDDe cx2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=tOauJKMgg2MIheNpatw8gIZjWUnov8KxvweDn05QQmo=; b=MjDLbJW2457A1kFEX5kr+LSwmSRkrZZ9qgBQIQrX+enbMLIJgL28w3HKiMgED2D/J/ nsTBWyzg1eQraE/yVs5CDhYbWOUnM6Jq8pj0aGICH25PUmEbA7lj9+vXdzQHOr/Wst4A eSWQuaZLA1zRoOWUssCWsJ/Kl76vOxHCPGYJBLMlCT2i6lZRn3Jn475V7/2skDcrCAOG JdkufM7FR1J1iaK6mvJkf7KJoS1R2oeO55l7FPGIe7MHx5B9oYRzlLdCu1Vfnla9/5RG t43nysfY7TQhOibXcICA9vePPO25bc4p/10zJ0tXtx1YtiYQk4wD4JHMTS+DTIVEM9Ar KoHg== ARC-Authentication-Results: i=1; mx.google.com; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z16si1115201edc.65.2021.03.05.09.32.25; Fri, 05 Mar 2021 09:32: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; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229709AbhCERa1 (ORCPT + 99 others); Fri, 5 Mar 2021 12:30:27 -0500 Received: from mail-ot1-f47.google.com ([209.85.210.47]:43184 "EHLO mail-ot1-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229551AbhCERaT (ORCPT ); Fri, 5 Mar 2021 12:30:19 -0500 Received: by mail-ot1-f47.google.com with SMTP id v12so2519436ott.10 for ; Fri, 05 Mar 2021 09:30:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=tOauJKMgg2MIheNpatw8gIZjWUnov8KxvweDn05QQmo=; b=H2aE8Cadb7mEto1MNFCBdHETtvR4qhk+WUPgq59/WGG0XFNYDAa6UpvSdoL778zu7h EYi+5trnxzun5/T+1DbtBh6CAWz3B5YY8Or+7CVFarvLA3H4nZ5OwhKxmP2egOA1dwAU Uj1VsDhsPR1JitXzSQphDUSfqab1uP6ESNTKSoAlWKVKb8k/hJxH4fZKaOv/lOdxv3+k igcxRMEXy2Wfry/n5IpGwtbuMI4hfHjkokYcFCJ6tmU9l2+aqDAs3et1nvGHbkb6LID5 HWWr1X6HnWYclT3/rCCTF029WbPsfmp0j0xW4nKsitsm7hDsHg1td+hes7spB88hURkJ iUrQ== X-Gm-Message-State: AOAM53188VBiR2fJ5pYzlI4NyCWuumKGFANf/3CwVkY4RNkieCCgs9xe xH1nKXNDpULs/2dHt9C+JADACEDLJkqXe/x9108= X-Received: by 2002:a05:6830:1057:: with SMTP id b23mr9243050otp.206.1614965418684; Fri, 05 Mar 2021 09:30:18 -0800 (PST) MIME-Version: 1.0 References: <20210305102405.14940-1-baijiaju1990@gmail.com> In-Reply-To: <20210305102405.14940-1-baijiaju1990@gmail.com> From: "Rafael J. Wysocki" Date: Fri, 5 Mar 2021 18:30:07 +0100 Message-ID: Subject: Re: [PATCH] base: dd: fix error return code of driver_sysfs_add() To: Jia-Ju Bai Cc: Greg Kroah-Hartman , "Rafael J. Wysocki" , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 5, 2021 at 11:24 AM Jia-Ju Bai wrote: > > 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 Reviewed-by: Rafael J. Wysocki > --- > 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 >