Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754051AbZJEQi6 (ORCPT ); Mon, 5 Oct 2009 12:38:58 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753895AbZJEQi6 (ORCPT ); Mon, 5 Oct 2009 12:38:58 -0400 Received: from mtagate8.uk.ibm.com ([195.212.29.141]:41295 "EHLO mtagate8.uk.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753707AbZJEQi5 (ORCPT ); Mon, 5 Oct 2009 12:38:57 -0400 Date: Mon, 5 Oct 2009 18:37:53 +0200 From: Cornelia Huck To: Phil Carmody Cc: gregkh@suse.de, linux-kernel@vger.kernel.org, Phil Carmody Subject: Re: [PATCH 1/1] Kobject: bail early if no new_parent in kobject_move() Message-ID: <20091005183753.4d77afcb@gondolin> In-Reply-To: References: Organization: IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martin Jetter =?ISO-8859-1?Q?Gesch=E4ftsf=FChrung:?= Erich Baier Sitz der Gesellschaft: =?ISO-8859-1?Q?B=F6blingen?= Registergericht: Amtsgericht Stuttgart, HRB 243294 X-Mailer: Claws Mail 3.7.2 (GTK+ 2.16.5; i486-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1338 Lines: 39 On Thu, 1 Oct 2009 17:50:48 +0300, Phil Carmody wrote: > From: Phil Carmody > > In the absense of kobj->kset, new_parent would remain NULL. > NULL-dereference shenanighans then ensues in the subsequent > sysfs_move_dir(..., new_parent) call. Bail early instead. But sysfs_move_dir(..., NULL) should work and fall back to the sysfs root... It seems that has been broken for some time. Should probably be something like this instead (uncompiled); I can send it with proper description and s-o-b once I gave it a test. --- fs/sysfs/dir.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- linux-2.6.orig/fs/sysfs/dir.c +++ linux-2.6/fs/sysfs/dir.c @@ -894,7 +894,8 @@ int sysfs_move_dir(struct kobject *kobj, mutex_lock(&sysfs_rename_mutex); BUG_ON(!sd->s_parent); - new_parent_sd = new_parent_kobj->sd ? new_parent_kobj->sd : &sysfs_root; + new_parent_sd = (new_parent_kobj && new_parent_kobj->sd) ? + new_parent_kobj->sd : &sysfs_root; error = 0; if (sd->s_parent == new_parent_sd) -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/