From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0E7D540862B for ; Mon, 15 Jun 2026 16:07:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781539676; cv=none; b=UxX5hU4bzBzAlVuTS8tOuOkh4sN1VGUcmDbuBX4g1DSq9huLKTxEByYjznE/528Km6HFq9IERGQEWLFVi2ytT3Kcc5aj4rQw+tuzRpbBQbjzNw6jEEvkviHzcyJJY2zQQCuO1E8zMdjZquZN3oHz1YPXZcMoVy7CytGBxYX2HqY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781539676; c=relaxed/simple; bh=BNWm3yBrWDSvhvRniGZ4hmT2BF78LFW7Pkimsfh59v4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ryPgpuKHRF3X2gH824Npz3+XvylpvgQv28CHm4rrPn+xoZrZkCUh+WlFcD8uiD49V+gCDHvul1ySQb39CXxnBPJc7Ju2638cn1w9H9fE1wf7Xc3VKkbakxTqqyXufD+5jQgum/uFxSQMbiBx/1wiakdBTeUpv6e8qBJxSI4GWNM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Hl0e4N5T; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=pSdygqvR; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Hl0e4N5T"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="pSdygqvR" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781539674; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=qqiCivCRQvHY+CsTahzYtUmnxa2excZbQQLs4Yc0u3c=; b=Hl0e4N5Ty0qJWd3wfEhgTOr0kBO+LTEuG1TrNkx+D1AAwF39jnM/YxZTqGbB0rr4/3RWeM OTGe45NeQdZ3te3/OACZ9aArdvOG+VVYG/6+GNJ1Dy+uUbuM9Al3ksvAZ3mCwdmQbwlH2I eRfezutItiyCc1Bh4kbcG0dpmk87R3w= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-564-rw-AN8HhM0GubNrLQqDu-g-1; Mon, 15 Jun 2026 12:07:52 -0400 X-MC-Unique: rw-AN8HhM0GubNrLQqDu-g-1 X-Mimecast-MFC-AGG-ID: rw-AN8HhM0GubNrLQqDu-g_1781539672 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-8cceaca5671so75897436d6.0 for ; Mon, 15 Jun 2026 09:07:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1781539672; x=1782144472; darn=vger.kernel.org; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=qqiCivCRQvHY+CsTahzYtUmnxa2excZbQQLs4Yc0u3c=; b=pSdygqvRdZTXml1YG1HBB/8+N9L3Iceh5yhV+VxVs9IoAbFmf5z2XBDZnFHDB2XJxH c6PG/3IzJihvrBCOczJdn0J1oVi5/iWV7AIXdjxk39cgHXnAHvMRQJB46poDhN97vkut RqEivhXzYRxaqRqssS+pV1+UXLskt6kj2P79c7gO9O8jBX94nhKmiOd1bAw65PK5eo9I 7nlCdXc+efNP5pVeQUXFKx0GGD0HuV+JmqqpC0oAS68bo1x8jYQgRT2E9l9y7R/YCobl SpuS1yPHfj0Ls9sp2HP2KM+LQv69iwZJFcqd/Nqy2ZR4q8vQhEtr7BPD2T+6wYlt31vA d3VQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781539672; x=1782144472; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=qqiCivCRQvHY+CsTahzYtUmnxa2excZbQQLs4Yc0u3c=; b=EPOtapuRkL1iIASJyho6dFKSZ5Q6w8jYbLw7DujALzo9N/yxoeCPItABdxWf5WmMl7 sFnyEXUQh5Av8czp1uxthnDXXN9/qS2WCFF5xh5sxGuSC2LjvXIIyW9uh9C3Y9Ano39+ cUA42FBfZl+c1eBw5xq5Ljs9zT6lbXBF0CxEHsRx5Uu5Vc06yZt2Tfk0HC0I3D5eivm1 qFym7TruRSsUhUm8cjEcmwbbQWgWX3ykYV+OmbvEb1X3e2G+GOc9tebHlLEdVSkTozAw zR+vn/ubkTNFc+Baz7vbFWgekH6/UHQtqVKSyCZTtfARtSF979zjP2YGYlrr8oikRba5 0RZg== X-Forwarded-Encrypted: i=1; AFNElJ/BNrDg3lD+C//fR3ne7s9dD+ZQVfoVRbwiNH1bwtqyhM8mKTL/q7gyUD8RglG71+22lD40czcsz5ZbdQE=@vger.kernel.org X-Gm-Message-State: AOJu0Yw/aSkL3FsPPEj2dK+pwBQF+u+aWFXZgBlL/5xeQCSB9e/A3C6V FncgedH6Wvt/TF/1UGmaNpIx9CFTc4Lko/RvseGJ7gG8m1qh2fni6eF+J1keSZxPpx3YNVHrN9v B+p+EG0Amx5onqJYo8PYJkOBEF9PrZAA0LV2+IecNbRecFdguJgwWMzkkz8tQ777lnQ== X-Gm-Gg: Acq92OF6LDgAJTjuT/1pZJGf/cZbUCmUwuTTkgFmk+DmDTWRwPVPpnUNTODl3Wodk6c BxCdS/6cpD5zoXUWKIz3UaizAsU0NmcKkMFAJ7qxuFPjr4+sWw0hbeqquIw9BXfNQJu5F784NEU QksKZ9dIp0Cy0PSuo6zSyPuDTECGIfpKErdytUOJ4tx4oZPVznVddqwGukpWs+kK2KphZBmSYeo x8m6iKXAsoO14ipoZmILgScs3mwQzKZxZRzrVpslM0qhHp81PpqA9dohgKUEZo7LwEzddkGNBz8 sURsRpLOitXCUdKBAYKf9jjs9cd9+yv8V2c+wT6ApgmwNnoFaDolxC7FNqOqQ3SN/EYUp3qFf4e zR6rNyarmCISHnFC6cOyW8f/uC6tHYk3of+54U8TYzR8oQ1x+TePreEbs X-Received: by 2002:ad4:5687:0:b0:8cc:e8f4:1636 with SMTP id 6a1803df08f44-8d9fdd239b2mr3018636d6.25.1781539672165; Mon, 15 Jun 2026 09:07:52 -0700 (PDT) X-Received: by 2002:ad4:5687:0:b0:8cc:e8f4:1636 with SMTP id 6a1803df08f44-8d9fdd239b2mr3018186d6.25.1781539671714; Mon, 15 Jun 2026 09:07:51 -0700 (PDT) Received: from redhat.com (c-73-183-52-120.hsd1.pa.comcast.net. [73.183.52.120]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8d9f1416a6csm2722726d6.3.2026.06.15.09.07.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jun 2026 09:07:50 -0700 (PDT) Date: Mon, 15 Jun 2026 12:07:43 -0400 From: Brian Masney To: William Theesfeld Cc: Michael Turquette , Stephen Boyd , Michal Simek , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] clk: zynq: handle kasprintf() failure in periph_clk registration Message-ID: References: <20260601203500.658135-1-william@theesfeld.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260601203500.658135-1-william@theesfeld.net> User-Agent: Mutt/2.3.1 (2026-03-20) On Mon, Jun 01, 2026 at 04:35:00PM -0400, William Theesfeld wrote: > zynq_clk_register_periph_clk() ignores the return value of the two > kasprintf() calls used to build the mux and divider clock names, and > passes the resulting (possibly NULL) pointers straight into > clk_register_mux(), clk_register_divider() and clk_register_gate() as > the clock '"'name'"' argument. On allocation failure that name later > gets dereferenced by the clock framework (e.g. in debugfs name > formatting), causing a NULL-pointer dereference. > > Check both kasprintf() returns. On failure unwind any allocated name > buffer and the spinlock, then fall through to the existing err label > which sets clks[] to ERR_PTR(-ENOMEM). Freeing the spinlock on the > error path is correct here because no clk_register_*() call has had > a chance to take ownership of it; the success path intentionally > hands it off to the registered clocks. > > The neighbouring zynq_clk_register_fclk() in the same file already > uses this per-allocation goto-label cleanup pattern; this change > brings periph_clk into line with it. > > Signed-off-by: William Theesfeld Reviewed-by: Brian Masney