From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1423177AbbEOBW2 (ORCPT ); Thu, 14 May 2015 21:22:28 -0400 Received: from mail-qg0-f45.google.com ([209.85.192.45]:35740 "EHLO mail-qg0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933595AbbEOBWZ (ORCPT ); Thu, 14 May 2015 21:22:25 -0400 Message-ID: <55554A4E.6040401@kernel.dk> Date: Thu, 14 May 2015 21:22:22 -0400 From: Jens Axboe User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Nicholas Krause CC: linux-kernel@vger.kernel.org Subject: Re: [PATCH] block:Add proper error handling to the function, disk_add_events References: <1431647831-14991-1-git-send-email-xerofoify@gmail.com> In-Reply-To: <1431647831-14991-1-git-send-email-xerofoify@gmail.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/14/2015 07:57 PM, Nicholas Krause wrote: > This adds the proper required error checking to the function, > disk_add_events for when there are no disk events by returning > the error code, -EBUSY. Further this also adds error checking > for when our call to the function, sysfs_create_files by making > this function's return now go into a newly declared variable, > ret and at the end of this function's body return it to indicate > whether this function is successful or not to the caller. > > Signed-off-by: Nicholas Krause > --- > block/genhd.c | 13 +++++++++---- > 1 file changed, 9 insertions(+), 4 deletions(-) > > diff --git a/block/genhd.c b/block/genhd.c > index 0a536dc..3eb7ee9 100644 > --- a/block/genhd.c > +++ b/block/genhd.c > @@ -1803,15 +1803,19 @@ static void disk_alloc_events(struct gendisk *disk) > disk->ev = ev; > } > > -static void disk_add_events(struct gendisk *disk) > +static int disk_add_events(struct gendisk *disk) > { > + int ret = 0; > if (!disk->ev) > - return; > + return -EBUSY; > + > + ret = sysfs_create_files(&disk_to_dev(disk)->kobj, disk_events_attrs) > > - /* FIXME: error handling */ > - if (sysfs_create_files(&disk_to_dev(disk)->kobj, disk_events_attrs) < 0) > + if (!ret) { > pr_warn("%s: failed to create sysfs files for events\n", > disk->disk_name); > + return ret; > + } You didn't even test this, obviously. -- Jens Axboe