Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754209AbdDKKQE (ORCPT ); Tue, 11 Apr 2017 06:16:04 -0400 Received: from mail-wr0-f182.google.com ([209.85.128.182]:35159 "EHLO mail-wr0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754091AbdDKKO4 (ORCPT ); Tue, 11 Apr 2017 06:14:56 -0400 To: linux-raid@vger.kernel.org, "linux-kernel@vger.kernel.org" Cc: Shaohua Li , NeilBrown From: Michael Wang Subject: [PATCH] md: return 0 instead of error in rdev_attr_show() Message-ID: <769019bb-84a1-044f-bac1-d44ff1ee9177@profitbricks.com> Date: Tue, 11 Apr 2017 12:14:48 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1383 Lines: 45 sysfs_kf_read() expect the show() callback return the dumped length, while rdev_attr_show() can return the error which lead into overflow: BUG: unable to handle kernel paging request at ffff88040b084000 IP: [] __memmove+0x24/0x1a0 PGD 1edb067 PUD 1ede067 PMD 406b9a063 PTE 800000040b084161 Oops: 0003 [#1] SMP [snip] Call Trace: [] ? sysfs_kf_read+0x80/0xb0 [] kernfs_fop_read+0xab/0x160 [] __vfs_read+0x28/0xd0 [] vfs_read+0x86/0x130 [] SyS_read+0x46/0xa0 [] entry_SYSCALL_64_fastpath+0x12/0x6a Simply return 0 in case of error solved the problem. Signed-off-by: Michael Wang --- drivers/md/md.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/md/md.c b/drivers/md/md.c index 1db88d7..d46d714 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -3271,10 +3271,9 @@ rdev_attr_show(struct kobject *kobj, struct attribute *attr, char *page) struct rdev_sysfs_entry *entry = container_of(attr, struct rdev_sysfs_entry, attr); struct md_rdev *rdev = container_of(kobj, struct md_rdev, kobj); - if (!entry->show) - return -EIO; - if (!rdev->mddev) - return -EBUSY; + if (!entry->show || !rdev->mddev) + return 0; + return entry->show(rdev, page); } -- 2.5.0