Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4271118pxf; Tue, 23 Mar 2021 07:02:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxelnvDD4wGPYq37WUTqeGqk/6AVF9q9qeNoAxyWQZoyuFlO9+HmNbX9flZBjkBWgzpwvZG X-Received: by 2002:a17:906:cd12:: with SMTP id oz18mr5116188ejb.498.1616508141124; Tue, 23 Mar 2021 07:02:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616508141; cv=none; d=google.com; s=arc-20160816; b=E6YATuF0UpfCAOfXmM5WnXymk27+gcVHEuqdzyhiIqnl9jU9ZN4X0Fh8MOubKLHm+m 6Xi4ZeuCDXhNvsB7/MF3UGzbWCZkUagiUR7k2BwxT1TvPm2sy/wSbyIFhMJdce0zjSpO ZKJQJK9AUF1eGe2ZP/Ysy05MQqBea78j/ONRaSKVrXVCGXqMHzON2f/8fzTtM/FbXjSb slrbK55q6POXVdgeLJ3yaANX0MVbUrIqZZF/xvoVuHWkI13WUHUM/m9qbcZ2xd5291O5 TSP3hGvKLDrrNdbyPq0GoU9YbYvLXnztloiACgwepLqY67E3ols2MD14NXmJYMKyDVax +coA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=x+EuTn/mbufzlw3xdL5sUn8dXcVWOLX8nqOp6WcqJeU=; b=JiueP4pvSf77nHmSbIVUKa0wQ9ReylwZk5gViiPt1s6EEpMdIgS1OdevdB2ddoCgsX WQDmy0K5gJ9GbZm9g1Za3LJ5F/+GLSKU6jOX06n1cmmBgEFlIuw8LpxfCv56MITKNW7T pwmIZSyNTN7xvvMyFBX0zh7hty8ipYtBHtMyaRt3Hpr62VzCM4lm66IvGwIjhAr1iB2n 0c2XlXYbnvb5hWBTNm1G3dBXjyMrR3KAwG6jApBImCQocQa9MFQ/98S4TLlx1cNNSaI1 V7sW8Sa1OOFFKiaaUMTyRlaVHt1EdJ+CUS+X4FdKm0sqNqCamrXWkwXVKnEVdYEX1adZ Ilzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="D4D/x9Yq"; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qc18si13637347ejb.574.2021.03.23.07.01.50; Tue, 23 Mar 2021 07:02:21 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b="D4D/x9Yq"; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231864AbhCWN6N (ORCPT + 99 others); Tue, 23 Mar 2021 09:58:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:54458 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231881AbhCWN5O (ORCPT ); Tue, 23 Mar 2021 09:57:14 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id ABE806199F; Tue, 23 Mar 2021 13:57:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1616507834; bh=TVlze4Ab3R9NxO0b358rAs/k/6d4Gmhz6b1U2HphJ+g=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=D4D/x9Yq0Rfe5UJtw5Ra2qU7dFcxXurblXVfdt398AuH5ocJBxjVUdrpVhsqgua8S bQVsTOwfmxj5Tl0O13tHS3rqLbDDDW2qrNcJ2KP+Afv4Sru2+P3FKbpB67Rrop5h+K VX3IGGSFHAXbj5zRCwU/243cHUqAa8AG8vjpdi30= Date: Tue, 23 Mar 2021 14:57:11 +0100 From: Greg KH To: Jia-Ju Bai Cc: rafael@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] base: dd: fix error return code of driver_sysfs_add() Message-ID: References: <20210305102405.14940-1-baijiaju1990@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210305102405.14940-1-baijiaju1990@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 05, 2021 at 02:24:05AM -0800, 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 > --- > 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; > + Trailing whitespace :(