From nobody Sun Jun 21 04:17:31 2026 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3D729258EF9 for ; Tue, 7 Apr 2026 14:32:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775572323; cv=none; b=UEhkXjtA5WPXmhM8MQDNh3Ct/iLFVzf8+/eZPJ0l4uuvp5fFhpL6rOxIHrMCoB/CRAoyIBPVfXyRCyEkBXlX/nslgExZtj6UIlaRntZwVkDqHn6+eA/KzzeEemaJIBea5d88Y4M/4EpE1RO5iZEm8/T14ZMJGufq8T6WNObWic4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775572323; c=relaxed/simple; bh=Hwkc18V7UnWYvRKdBZWpOF4mija3KB5Yt4sYIH5szJo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FOOPONW+5q4CeHcoyBtJRJ+VeXr+yGWCVOWewOkEPCfnbqU2TY1NP/WjhEMLM1oO+YSOym+Jt/QGNfWH9U+OluRqH0/dPsWMclCzSZacmM8+m8lAhDUdkBIwoVHuV27I7mV+vnseFBLvKQw8C8mN+ThyyG/HiMDKnxrRHerwnBw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=rQPVVxhk; arc=none smtp.client-ip=209.85.214.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="rQPVVxhk" Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-2aae4816912so32301055ad.2 for ; Tue, 07 Apr 2026 07:32:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775572321; x=1776177121; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=aWlqSctU1ZNN/z0ZDozfOPMSEatR6CHgCywrgmA5uDE=; b=rQPVVxhkEd0o5tOJeTOk+/cyi1lcobMbxZSrqRFcS64TBGiDKHrbmu4LNIN6kM47+l y0Yq0kjwilOQWNDfUXumKd0w05uC6l3YaY1tudxXSybFmrvjC73Zp2pIUdHVfhZpZgaU a1oD2iVjv6uTVZFpd3gAOmNdHv9H2ddYQddP+l03Qmzk5NdJMWDihKtVCAcUZ6AD155L pJUJn55FEo7OECVUTuNGucISw6ijNLMYGxat4IGxQ1gfSt2/WhCanVjfjVKwYwszpRTs T219MzKD7ol/JFtdSEb4/t6qwMQnV0cFNU6Z4zGIhtQxTszONf+nv9TOv0er9Z+ag98i 8EKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775572321; x=1776177121; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=aWlqSctU1ZNN/z0ZDozfOPMSEatR6CHgCywrgmA5uDE=; b=DuBUEacup42Gbs2ixea7oQb5IdMybzP0/wrr/aQcmGr6EQVHlnfIXmKGY1zEoaTnvq ta1wpbNfIohI/fZ3VAAAWdkyigzv2Us5bwWgE0XwqdtuO7E8x/0fKl4jm/qA8Ecao5Fn G+8t4yaKy3FrHPWHMcHm5CcVhHQ75bp/sCdWWm6Ev4YI+RKapAy+RKvreixkmFtzMqHn BU2vUd1vilXqUr4QTW5OL0mReQX0DT3pnxwITvtuwxwrH3/ZUqLIK7bgmsu/1ZKMwJsM yaqeYqKN6/fE0QpWoFGQpXuhwH+RH97Dx4azSDtuU4TlGl3tfZMMPbT0ulkWc+KjWi6I UIRg== X-Forwarded-Encrypted: i=1; AJvYcCXcALe5MiwOPCRFOYT/3kp4nAocsVYuS4k80PFAZwpL//UOW9aY6LxLNljfu/LahUBmOQXZI+IxkvOo/fE=@vger.kernel.org X-Gm-Message-State: AOJu0YylbD/Wkv913YBbAvT1o4M10f6LYzfTEpl1euHwZO9yM2CQkQtr 9mbS/XSZJLiB4Q3ChkYKcFSmx7iCPUKAyvfkAyKdXdbA2MP1Ey0OspQh X-Gm-Gg: AeBDiettMubD6dFmfulVvLbot7wsO9M/+npaeClwlfc+I5pvZQpb67WtgSG10M6baiR sqEVZFMfDJwXL9gYMt5nUngAz6MAM4/CdQjP0ZU8MwYo+hEi2tTGfdLZiLyf96BxVetxw8xsQ/B qAoDfA+P3Q2fRLmMoDoEcz1FId/+719jBZtjixHcI1O3xNUAUA7hwrFyYHnj1Ej/jBst4WcS0f/ 8gR2PvTlxQf5iGbtNldO4sPnG7XmF8I9pQIEpX3cVqF6HmJhPrZVHK3bnq4/BZwNWrt5ZaIdkvP 2D0xGhFwss8jNNsi0tzw88Ys9OnYdDNo3uhlDpJkAeRlNqyf/ESqxEHCTXF6Go6tqtoYITqgipP jWfUAxjvI1uYjzeSCaYF99N0pkZSFF9WBLQVVzwe65xC02dV748WzGZmblsaIPQTHL1kTlf0y8+ EzEnxkm4crYh/MDZKvlFLrhdWJ5LX8xes19eiv89P966J1XU6nEHEel2zjqsRD X-Received: by 2002:a17:903:3b84:b0:2b2:4728:aa6f with SMTP id d9443c01a7336-2b2818016cemr160584395ad.26.1775572321227; Tue, 07 Apr 2026 07:32:01 -0700 (PDT) Received: from Mac.localdomain.com ([49.205.216.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b2749cbc58sm181201525ad.78.2026.04.07.07.31.57 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 07 Apr 2026 07:32:00 -0700 (PDT) From: "Ritesh Harjani (IBM)" To: linuxppc-dev@lists.ozlabs.org, Haren Myneni Cc: Madhavan Srinivasan , Christophe Leroy , Venkat Rao Bagalkote , Nicholas Piggin , linux-kernel@vger.kernel.org, "Ritesh Harjani (IBM)" , Christian Brauner Subject: [RFC v1 1/6] pseries/papr-hvpipe: Fix null ptr deref in papr_hvpipe_dev_create_handle Date: Tue, 7 Apr 2026 20:01:35 +0530 Message-ID: <5984bd91ad6d3541d08dc9f3c99e6de0214dbfcc.1775569027.git.ritesh.list@gmail.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Getting the following kernel panic in papr_hvpipe_dev_create_handle() when trying to add src_info to the list. Kernel attempted to write user page (0) - exploit attempt? (uid: 0) BUG: Kernel NULL pointer dereference on write at 0x00000000 Faulting instruction address: 0xc0000000001b44a0 Oops: Kernel access of bad area, sig: 11 [#1] ... Call Trace: papr_hvpipe_dev_ioctl+0x1f4/0x48c (unreliable) sys_ioctl+0x528/0x1064 system_call_exception+0x128/0x360 system_call_vectored_common+0x15c/0x2ec The error handling with FD_PREPARE's file cleanup and __free(kfree) auto cleanup is getting too convoluted. This is mainly because we need to ensure only 1 user get the srcID handle. To simplify this, we allocate prepare the src_info in the beginning and add it to the global list under a spinlock after checking that no duplicates exist. This simplify the error handling where if the FD_ADD fails, we can simply remove the src_info from the list. Cc: Christian Brauner Fixes: 6d3789d347a7 ("papr-hvpipe: convert papr_hvpipe_dev_create_handle() = to FD_PREPARE()") Reported-by: Haren Myneni Signed-off-by: Ritesh Harjani (IBM) Reviewed-by: Christian Brauner --- arch/powerpc/platforms/pseries/papr-hvpipe.c | 50 +++++++++----------- 1 file changed, 22 insertions(+), 28 deletions(-) diff --git a/arch/powerpc/platforms/pseries/papr-hvpipe.c b/arch/powerpc/pl= atforms/pseries/papr-hvpipe.c index 14ae480d060a..ef10f5a5a4fa 100644 --- a/arch/powerpc/platforms/pseries/papr-hvpipe.c +++ b/arch/powerpc/platforms/pseries/papr-hvpipe.c @@ -479,21 +479,8 @@ static const struct file_operations papr_hvpipe_handle= _ops =3D { static int papr_hvpipe_dev_create_handle(u32 srcID) { - struct hvpipe_source_info *src_info __free(kfree) =3D NULL; - - spin_lock(&hvpipe_src_list_lock); - /* - * Do not allow more than one process communicates with - * each source. - */ - src_info =3D hvpipe_find_source(srcID); - if (src_info) { - spin_unlock(&hvpipe_src_list_lock); - pr_err("pid(%d) is already using the source(%d)\n", - src_info->tsk->pid, srcID); - return -EALREADY; - } - spin_unlock(&hvpipe_src_list_lock); + struct hvpipe_source_info *src_info; + int fd; src_info =3D kzalloc_obj(*src_info, GFP_KERNEL_ACCOUNT); if (!src_info) @@ -503,26 +490,33 @@ static int papr_hvpipe_dev_create_handle(u32 srcID) src_info->tsk =3D current; init_waitqueue_head(&src_info->recv_wqh); - FD_PREPARE(fdf, O_RDONLY | O_CLOEXEC, - anon_inode_getfile("[papr-hvpipe]", &papr_hvpipe_handle_ops, - (void *)src_info, O_RDWR)); - if (fdf.err) - return fdf.err; - - retain_and_null_ptr(src_info); - spin_lock(&hvpipe_src_list_lock); /* - * If two processes are executing ioctl() for the same - * source ID concurrently, prevent the second process to - * acquire FD. + * Do not allow more than one process communicates with + * each source. */ - if (hvpipe_find_source(srcID)) { + spin_lock(&hvpipe_src_list_lock); + if(hvpipe_find_source(srcID)) { spin_unlock(&hvpipe_src_list_lock); + pr_err("pid(%d) could not get the source(%d)\n", + src_info->tsk->pid, srcID); + kfree(src_info); return -EALREADY; } list_add(&src_info->list, &hvpipe_src_list); spin_unlock(&hvpipe_src_list_lock); - return fd_publish(fdf); + + fd =3D FD_ADD(O_RDONLY | O_CLOEXEC, + anon_inode_getfile("[papr-hvpipe]", &papr_hvpipe_handle_ops, + (void *)src_info, O_RDWR)); + if (fd < 0) { + spin_lock(&hvpipe_src_list_lock); + list_del(&src_info->list); + spin_unlock(&hvpipe_src_list_lock); + kfree(src_info); + return fd; + } + + return fd; } /* -- 2.39.5 From nobody Sun Jun 21 04:17:31 2026 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C139327AC28 for ; Tue, 7 Apr 2026 14:32:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775572327; cv=none; b=RytuneJaQmFfRTK18rd6eDcHXdW3PUYiOwkID7pvFk99v3xYdKtfyVmvDrl3TPx4BlGu9K4nsNNolEupwS2LP66yGVOV83mH1Jmi6Nxl1aYhsLo3IDh/d/2sWINX2hsXObx26uWc3mjqwucloyUHla7b+JJet45fMCHVwC9/EpE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775572327; c=relaxed/simple; bh=iKRQagKpgt4ce23lOhLNeNiGvj47gYzVTtg2Yvk6aYs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oOwj9It+W55m/+csPY8TM2LDkZ5NIeNL+pNCBA6RQD3OFwykW0uRhQ6CBEoST1NBSZV5kmrpps90J+QAC748MPfgdquFnyOS1UUtT8XKqitMzhTDsy/qRoupUdcqs+B4Oa56S4Woc9pwCRugRdWYJNPTAfiqOAFz/9UW6gPgpFk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=IpBTThDi; arc=none smtp.client-ip=209.85.214.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="IpBTThDi" Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-2a8fba3f769so20126915ad.2 for ; Tue, 07 Apr 2026 07:32:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775572325; x=1776177125; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qgL4Qq7YZCy8/RvaSgFHNT5E42dfIeMN6C/f1hBgwoQ=; b=IpBTThDiCDkjsvH1UcUGmbdw48RWTASB/3MuMsdyGUyDD3NO8PcRSbXmBPedyIQ2AN 2TdpZziNZazZS4vHNN8cNoMigBT16uoakIDIezpcI8y3u1ibNVxnVLw2LyvYzgYw9XAM zysx7yR9mOsJ6B3rmU+UkHD2z6uckki6h+bq09xwPBKqy1bKHZxziHaXrWZ7EvgJ9jeC f6VgawTQx9ZtalY3k8n7pDrCD7c3VecM7V+iT0lpt+rLpEBeCMpECDsUA3N7sRv6kbUQ n4/7ogfwhqsuOTsE400JoEH6mItJoRsDWbLr5dAP3dqS/dxyifroOH869QDWzlNGP13x uAmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775572325; x=1776177125; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=qgL4Qq7YZCy8/RvaSgFHNT5E42dfIeMN6C/f1hBgwoQ=; b=TrnohagXE1CXJLzY0m1604zqxXts+Fi/MhLFV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b0:2b0:afb4:7d41 with SMTP id d9443c01a7336-2b2817159bdmr182384625ad.10.1775572325101; Tue, 07 Apr 2026 07:32:05 -0700 (PDT) Received: from Mac.localdomain.com ([49.205.216.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b2749cbc58sm181201525ad.78.2026.04.07.07.32.01 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 07 Apr 2026 07:32:04 -0700 (PDT) From: "Ritesh Harjani (IBM)" To: linuxppc-dev@lists.ozlabs.org, Haren Myneni Cc: Madhavan Srinivasan , Christophe Leroy , Venkat Rao Bagalkote , Nicholas Piggin , linux-kernel@vger.kernel.org, "Ritesh Harjani (IBM)" Subject: [RFC v1 2/6] pseries/papr-hvpipe: Fix the usage of copy_to_user() Date: Tue, 7 Apr 2026 20:01:36 +0530 Message-ID: <7e618bc382608acc390054786e3119db2856822b.1775569027.git.ritesh.list@gmail.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" copy_to_user() return bytes_not_copied to the user buffer. If there was an error writing bytes into the user buffer, i.e. if copy_to_user returns a non-zero value, then we simply return -EFAULT from the ->read() call. Signed-off-by: Ritesh Harjani (IBM) --- arch/powerpc/platforms/pseries/papr-hvpipe.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/arch/powerpc/platforms/pseries/papr-hvpipe.c b/arch/powerpc/pl= atforms/pseries/papr-hvpipe.c index ef10f5a5a4fa..fffebbae113c 100644 --- a/arch/powerpc/platforms/pseries/papr-hvpipe.c +++ b/arch/powerpc/platforms/pseries/papr-hvpipe.c @@ -206,10 +206,11 @@ static int hvpipe_rtas_recv_msg(char __user *buf, int= size) bytes_written, size); bytes_written =3D size; } - ret =3D copy_to_user(buf, + if (copy_to_user(buf, rtas_work_area_raw_buf(work_area), - bytes_written); - if (!ret) + bytes_written)) + ret =3D -EFAULT; + else ret =3D bytes_written; } } else { @@ -376,7 +377,7 @@ static ssize_t papr_hvpipe_handle_read(struct file *fil= e, =20 ret =3D copy_to_user(buf, &hdr, HVPIPE_HDR_LEN); if (ret) - return ret; + return -EFAULT; =20 /* * Message event has payload, so get the payload with --=20 2.39.5 From nobody Sun Jun 21 04:17:31 2026 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D9D4D221DAE for ; Tue, 7 Apr 2026 14:32:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775572331; cv=none; b=HXH538dukSZpx7gQIC9TKFflA8+K1V74kIMHa0I3T8CROrrP5dIp0AxwcA6xr6NOo4MqLLLXxPvuyLYKHL1KtaoYTuzRYdv2G9v0mtTxVtM+7y4a3B6ePPAKEnVqWEikVM7z5GcQHG8ewdDLL5cbKNCKVd/41iZd1mVpDS7R2kY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775572331; c=relaxed/simple; bh=kKGne6Sj2Dv6iv9zLXmPiHHoAQ0O1EugDBYCMpZ2KNE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KvCinC6BPYc2n1TduluITFKGS4Cvjo2xuEJHxTXsCL4DUU+9b3a6TqgE3vT/R/C0vDGmjyE/fdd/nGInmwPoba9vJHYkkond+V39aHfG82srILaKQ+KfdFqxr78vDseYMyp3/nwViD4sH6LSw4r1JFYHP0GicK9TACBSVwtnBi8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=GbM3mkcm; arc=none smtp.client-ip=209.85.214.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GbM3mkcm" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-2b24fdac394so50899515ad.3 for ; Tue, 07 Apr 2026 07:32:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775572329; x=1776177129; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fS3FVRjX3+s9MHoE+khprd5qCb8Si71RJNdFfwJc+pc=; b=GbM3mkcmr9sOhRx6EbnwjWeCJGDairywByUR5ZHgswbMmpkHJl76C9s0bOrTCMrAf0 ue8OJg3w8XwRF7kjz48DSVt+S7RURye5g1Cu9B4HNIfczXYiVlvZ3GrJs+hMVFjADY4e FdhiHK0qiHddUH40vgbcQGbqChSC0bT8FXrkGeeaGxEQEVTH8RuVAqCLcDZkbVDl0bNl sgEsW/msQgrKvk+J8AMNuM6yOozKi8ME4DLVNaXV3Vrsps+JPzZxxA+pT2xL73UoOppo 9rHrdB+AGcKza2aPS6A/NinlLmEisujMLUyisqOOyKWxT6YHVqHhXf6HxPvSwr2FkiNC TfVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775572329; x=1776177129; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=fS3FVRjX3+s9MHoE+khprd5qCb8Si71RJNdFfwJc+pc=; b=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FOHvG5m4sAUkrBOw7bni X-Received: by 2002:a17:903:1b70:b0:2b0:bebb:1081 with SMTP id d9443c01a7336-2b281799025mr198432295ad.28.1775572329159; Tue, 07 Apr 2026 07:32:09 -0700 (PDT) Received: from Mac.localdomain.com ([49.205.216.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b2749cbc58sm181201525ad.78.2026.04.07.07.32.05 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 07 Apr 2026 07:32:08 -0700 (PDT) From: "Ritesh Harjani (IBM)" To: linuxppc-dev@lists.ozlabs.org, Haren Myneni Cc: Madhavan Srinivasan , Christophe Leroy , Venkat Rao Bagalkote , Nicholas Piggin , linux-kernel@vger.kernel.org, "Ritesh Harjani (IBM)" Subject: [RFC v1 3/6] pseries/papr-hvpipe: Simplify spin_unlock() usage in papr_hvpipe_handle_release Date: Tue, 7 Apr 2026 20:01:37 +0530 Message-ID: <4217692a276ccae03f764f746e3607757277cbda.1775569027.git.ritesh.list@gmail.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Once the src_info is removed from the global list, no one can access it. This simplies the usage of spin_unlock() in papr_hvpipe_handle_release() Signed-off-by: Ritesh Harjani (IBM) --- arch/powerpc/platforms/pseries/papr-hvpipe.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/platforms/pseries/papr-hvpipe.c b/arch/powerpc/pl= atforms/pseries/papr-hvpipe.c index fffebbae113c..57ec50e3e883 100644 --- a/arch/powerpc/platforms/pseries/papr-hvpipe.c +++ b/arch/powerpc/platforms/pseries/papr-hvpipe.c @@ -455,6 +455,7 @@ static int papr_hvpipe_handle_release(struct inode *ino= de, src_info =3D file->private_data; list_del(&src_info->list); file->private_data =3D NULL; + spin_unlock(&hvpipe_src_list_lock); /* * If the pipe for this specific source has any pending * payload, issue recv HVPIPE RTAS so that pipe will not @@ -462,10 +463,8 @@ static int papr_hvpipe_handle_release(struct inode *in= ode, */ if (src_info->hvpipe_status & HVPIPE_MSG_AVAILABLE) { src_info->hvpipe_status =3D 0; - spin_unlock(&hvpipe_src_list_lock); hvpipe_rtas_recv_msg(NULL, 0); - } else - spin_unlock(&hvpipe_src_list_lock); + } =20 kfree(src_info); return 0; --=20 2.39.5 From nobody Sun Jun 21 04:17:31 2026 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 40DFD1EB5FD for ; Tue, 7 Apr 2026 14:32:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775572335; cv=none; b=hW1/7y+3S4rLoMMJ+Fyhok2EaqLtw0C9hxqIgD9G+zNY/iS62R6M8YS9TyRLFeotFAWuXix3NVxIVwkMRRufcElCAUey5QWuHmpt1Lqgmp2Sk6EmUsUvOe6xxkavczPvGEkMLtOtTmCNMyxIau1bUNoZQmgah65SMUQ0wwGwH8A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775572335; c=relaxed/simple; bh=GTeV3eMsMF5TBUbL4wF+FPJ3T0wnH7Hqs0WZOjIQXZA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Tick4S7VBQBv0toEEKsSAWCrPPEfuwUZ7LrnNHOhKP4ADLotnPiQVi/4gkg13Vxb7a0Tj86u06C/DW+PL77GYnGMwweE2K2U2TgTC42tfZA+Jg0f1+oyzE+FqGlC5fS4QaMKG2idIR1kAuf4adgRfbGtx4KX9vHBo+SZino8I4k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=REZkY9C6; arc=none smtp.client-ip=209.85.214.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="REZkY9C6" Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-2b258576d8cso32473145ad.0 for ; Tue, 07 Apr 2026 07:32:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775572333; x=1776177133; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Pe/uIRrlspU3/PcFgSkVRxo4DJTV1t3LxD3GPeG8ybc=; b=REZkY9C6a5WzDX2JnxMpYrlMX/FCsmX9RL5x+/Od9WqwwXO1T9JVcJj43Mbmvrk07G jgkIEZ79kP4qfwGuXUhO5HXTUjQlvDP41Z8fUhrxvHVHmhB9hyvo8Bd1FCReU96XpiLJ KpaO3/Q/yUHQQZk0eQzcgS6FUFZwmbaOgE+0YAzsJihucFxjef0B+hgp+D1jAT6Zfli/ olrAUYISfqsUJMfGynmZU+nh4rV6Y3bsogxbhDwiiEyEe3rjhRM/lVrNKM8YL9Juzo31 QEoH/5lVRaRphQ3eyjmLcjakoHaohYoE9HzYzy7o5DVtcpGkt68LfRheCRQQvj4HHWQS nxMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775572333; x=1776177133; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-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NCxNfKGWJyZe44iWNGA9pqljj8XtcO/pJfdDYWRtbmuRhkNx4O76dFnfPNR+UkN aBt5noH8X5BegcRB4J+Z8yPObn1/89ocr/x1kUuInwGgHaw/fJMA== X-Received: by 2002:a17:903:3b84:b0:2b2:4ffc:a7c4 with SMTP id d9443c01a7336-2b2818b3addmr165803545ad.24.1775572333419; Tue, 07 Apr 2026 07:32:13 -0700 (PDT) Received: from Mac.localdomain.com ([49.205.216.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b2749cbc58sm181201525ad.78.2026.04.07.07.32.09 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 07 Apr 2026 07:32:12 -0700 (PDT) From: "Ritesh Harjani (IBM)" To: linuxppc-dev@lists.ozlabs.org, Haren Myneni Cc: Madhavan Srinivasan , Christophe Leroy , Venkat Rao Bagalkote , Nicholas Piggin , linux-kernel@vger.kernel.org, "Ritesh Harjani (IBM)" Subject: [RFC v1 4/6] pseries/papr-hvpipe: Kill task_struct pointer from struct hvpipe_source_info Date: Tue, 7 Apr 2026 20:01:38 +0530 Message-ID: <108d32a56d9d4630ed2ba7d8ecce9679adf8671f.1775569027.git.ritesh.list@gmail.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" We don't really use task_struct pointer for anything meaningful. So just kill it for now, and we can bring back later if we need this for any future debug purposes. Signed-off-by: Ritesh Harjani (IBM) --- arch/powerpc/platforms/pseries/papr-hvpipe.c | 5 ++--- arch/powerpc/platforms/pseries/papr-hvpipe.h | 1 - 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/arch/powerpc/platforms/pseries/papr-hvpipe.c b/arch/powerpc/pl= atforms/pseries/papr-hvpipe.c index 57ec50e3e883..7242a14eb5ec 100644 --- a/arch/powerpc/platforms/pseries/papr-hvpipe.c +++ b/arch/powerpc/platforms/pseries/papr-hvpipe.c @@ -487,7 +487,6 @@ static int papr_hvpipe_dev_create_handle(u32 srcID) return -ENOMEM; =20 src_info->srcID =3D srcID; - src_info->tsk =3D current; init_waitqueue_head(&src_info->recv_wqh); =20 /* @@ -497,8 +496,8 @@ static int papr_hvpipe_dev_create_handle(u32 srcID) spin_lock(&hvpipe_src_list_lock); if(hvpipe_find_source(srcID)) { spin_unlock(&hvpipe_src_list_lock); - pr_err("pid(%d) could not get the source(%d)\n", - src_info->tsk->pid, srcID); + pr_err("pid(%s:%d) could not get the source(%d)\n", + current->comm, task_pid_nr(current), srcID); kfree(src_info); return -EALREADY; } diff --git a/arch/powerpc/platforms/pseries/papr-hvpipe.h b/arch/powerpc/pl= atforms/pseries/papr-hvpipe.h index c343f4230865..4bdf7bb2fc4d 100644 --- a/arch/powerpc/platforms/pseries/papr-hvpipe.h +++ b/arch/powerpc/platforms/pseries/papr-hvpipe.h @@ -21,7 +21,6 @@ struct hvpipe_source_info { u32 srcID; u32 hvpipe_status; wait_queue_head_t recv_wqh; /* wake up poll() waitq */ - struct task_struct *tsk; }; =20 /* --=20 2.39.5 From nobody Sun Jun 21 04:17:31 2026 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2CDED2BE7DB for ; Tue, 7 Apr 2026 14:32:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775572339; cv=none; b=RO5fhX7D9aDjfpqyAEzLzMyE5IsZGuehVCTSDFcHE4KlTRh6gowvdSHGZIS1IHazyfUmgcAVHJeD6Jzh10WT2+8EY8vd8RYCzTNTBeFCPlM85qVfPHjXXdZB6CudbTC0hW24M37FrlYoE5me4EXy8je1wG2lqApaRuETwiLmVTA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775572339; c=relaxed/simple; bh=2VKrCPDi3pKTXYq0V1T3BBsCsCo51omN0tE2jlm/9Ys=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=srCVCp973sp/Un4mt/KnHfhIqt7DNviCFsuqUzjCFMaNEkDG4dn/ggUj9hM5SpM2fpCZV5WsGCVSANyNgcLQ0vje03kLyIiNvyQknj0s/Lb/RMhFCM9tn2w/vsJcFNYVvUhQyNIo5Taf6kCEE/CSaER7TTfCKKkVzvEh3vxs4/4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Pug3AKBC; arc=none smtp.client-ip=209.85.214.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Pug3AKBC" Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-2ad21f437eeso25843365ad.0 for ; Tue, 07 Apr 2026 07:32:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775572337; x=1776177137; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WCaF3kLdCiAgYQ5/bk3SyXEWPD5dHMX+3j2VLCRYM2s=; b=Pug3AKBCkqlV1AlQ9RUts5p8n+zd+hry+FiWb8r9gGgqqDfLJU7ziJcTkGS2OlOh9a jD1NnOqT3UPmnLhbsYnFaxTA5rdc8ZFJ46mGU+G8veFHyOYMVBFvNT0qValyZyQ4Ouda kX1XcBzibkNKSjN/NhznoWLNCukF0WPEi1lfLu1MNZ2j/XIdJSCxm0H91KwITGo5ZjH3 mq/3aRyfStrMx/jr9M3BbWBUGmzFVVh8q9WWZX3EhxGysCr03Z7yAIQLPnWPQbGXkNue 86qVXX9GYauYYORkot0bmOLWDdFJDJ6lCs6ICK7Bcp0kK2K+EeFtPPg+H/7u46Yy0ehn GQag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775572337; x=1776177137; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=WCaF3kLdCiAgYQ5/bk3SyXEWPD5dHMX+3j2VLCRYM2s=; b=rhK3Uo4EYfjFt0TeB2Y7goJ73XHHFh3PUxDKznRCxwDlmADpCyPX+MtfRoa1DV5get RX+JDO4/Pdv0ElEYUZX3xV3UCDSOLjLD/CJKjnxUISGePOnIgIVDcWOAZBSnuK51bu0P sTmpoiggs7NSSMWnh0+aEUnRjt0g5ZZ9i/pPrWhvy7w4ODb1s9fS8fcfFBQADRqHwhMY AiyhgocvU6iBci8fLo+BTmIC+zgmqpjO0TYCJ0ES81gU/Hi6orbwXPXnqmTR0uie+ryD FwKFGsXdTJClZ61WXxSTO+507LhfRQOQA8Kh4WPxCgTVwx1QFmOalKQrtqSc4nTf7hho ZFDg== X-Forwarded-Encrypted: i=1; AJvYcCUFytmJ8JV8BrpexfeELsDqI8Gv05T17zooCUwhp39jiOLcMtUuNhyvnFt3irGiP5O1m9oy/eXStxbNByU=@vger.kernel.org X-Gm-Message-State: AOJu0YxwaXtkgvKDGJp5I48AFWqGKHjHdIbPuh8ZNir9SmvtAuQRkjRI 2BSezr3BlhZLenLY4bOoS3DsaiktxCb7PlosZ0L6x4Xr8PPqa3CQzDIW X-Gm-Gg: AeBDies3P+VJE5qqoYRzQS+TmC5GwdkueS3oP4o4j9eijUW0dSUUbboDjQgmaMhUmTd fdNUW5o+jEqINKCbRgOPjVz+ZrhFGVb1IrpqR/z0kmdI6zo1/teFEqH+HZXT4xlDadkAzBN3KKT 7WtEzVdLlyFFpd4hdl9IwAacghcSjumtHMTFWMOzzPSCvlgufr0nxWEs2J+44gYWRbdLJxyP4Vb ym8zA9yykei+3UD/nSod8SB73p92Lq9VVjhH07fc8oV7Oc+hwaTUCm19yTDLVGH/uKM7TC9H6rj ZgifvavNkXKXg8NUm/2I5QfL20ipja7M1o1/IJqViRMbJ0PC8kXIdH9k0MhK7U2iY8LUxS9/6uV vMnkOTUZyvaCmrX5qcAl6Ml2zMQQcdyBjMRO6998qebX2X8clIsnx7XtgXOcOidaN7PKpMHDs44 SB3Y0DdI5DpFm0EmcQsfTFD8fTYhi/bxschP/5kZp8LF/xhGzolQeuNCZVX2OE X-Received: by 2002:a17:903:1b0c:b0:2b0:6068:4c5f with SMTP id d9443c01a7336-2b277d966bdmr184775385ad.8.1775572337304; Tue, 07 Apr 2026 07:32:17 -0700 (PDT) Received: from Mac.localdomain.com ([49.205.216.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b2749cbc58sm181201525ad.78.2026.04.07.07.32.13 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 07 Apr 2026 07:32:16 -0700 (PDT) From: "Ritesh Harjani (IBM)" To: linuxppc-dev@lists.ozlabs.org, Haren Myneni Cc: Madhavan Srinivasan , Christophe Leroy , Venkat Rao Bagalkote , Nicholas Piggin , linux-kernel@vger.kernel.org, "Ritesh Harjani (IBM)" Subject: [RFC v1 5/6] pseries/papr-hvpipe: Refactor and simplify hvpipe_rtas_recv_msg() Date: Tue, 7 Apr 2026 20:01:39 +0530 Message-ID: <51b10f1e82e5c9965902b34b082a4d2aa981ff8f.1775569027.git.ritesh.list@gmail.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Simplify hvpipe_rtas_recv_msg() by removing three levels of nesting... if (!ret) if (buf) if (size < bytes_written) ... this refactoring of the funcion ensures bail out routines are handled early, to simplify the function logic. Signed-off-by: Ritesh Harjani (IBM) --- arch/powerpc/platforms/pseries/papr-hvpipe.c | 52 ++++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/arch/powerpc/platforms/pseries/papr-hvpipe.c b/arch/powerpc/pl= atforms/pseries/papr-hvpipe.c index 7242a14eb5ec..f41f5c0a8418 100644 --- a/arch/powerpc/platforms/pseries/papr-hvpipe.c +++ b/arch/powerpc/platforms/pseries/papr-hvpipe.c @@ -190,34 +190,34 @@ static int hvpipe_rtas_recv_msg(char __user *buf, int= size) return -ENOMEM; } =20 - ret =3D rtas_ibm_receive_hvpipe_msg(work_area, &srcID, - &bytes_written); - if (!ret) { - /* - * Recv HVPIPE RTAS is successful. - * When releasing FD or no one is waiting on the - * specific source, issue recv HVPIPE RTAS call - * so that pipe is not blocked - this func is called - * with NULL buf. - */ - if (buf) { - if (size < bytes_written) { - pr_err("Received the payload size =3D %d, but the buffer size =3D %d\n= ", - bytes_written, size); - bytes_written =3D size; - } - if (copy_to_user(buf, - rtas_work_area_raw_buf(work_area), - bytes_written)) - ret =3D -EFAULT; - else - ret =3D bytes_written; - } - } else { - pr_err("ibm,receive-hvpipe-msg failed with %d\n", - ret); + /* + * Recv HVPIPE RTAS is successful. + * When releasing FD or no one is waiting on the + * specific source, issue recv HVPIPE RTAS call + * so that pipe is not blocked - this func is called + * with NULL buf. + */ + ret =3D rtas_ibm_receive_hvpipe_msg(work_area, &srcID, &bytes_written); + if (ret) { + pr_err("ibm,receive-hvpipe-msg failed with %d\n", ret); + goto out; } =20 + if (!buf) + goto out; + + if (size < bytes_written) { + pr_err("Received the payload size =3D %d, but the buffer size =3D %d\n", + bytes_written, size); + bytes_written =3D size; + } + + if (copy_to_user(buf, rtas_work_area_raw_buf(work_area), bytes_written)) + ret =3D -EFAULT; + else + ret =3D bytes_written; + +out: rtas_work_area_free(work_area); return ret; } --=20 2.39.5 From nobody Sun Jun 21 04:17:31 2026 Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 10F0E2C15B5 for ; Tue, 7 Apr 2026 14:32:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775572343; cv=none; b=rVaG9iU1huMLmWkr5iDs/Ai8CROMw4H5wcqHd1hC+hIjiCgLoIIsUiPBLlmFW/KRzDeTyAjb1BWWVe4OkInT71ePWTmnNXmmGQXrAZ707s5AACWmO7P/fhXED1/82UxKaG//ktASXReyYRsx7g4QxT0ky7Uyu5zU2ZwtPHuBf88= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775572343; c=relaxed/simple; bh=cpDEHoVHwyFqV9HkmQmw2SPLd4T6pLmzYa0QuFcZkSc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ajRt5MK6ITs4kXyj8fAcsT3gzNXgq8e4ATgIRzFh7f21V37Anc27uaP71fVYDcBoMGOsy2K7reoNcMQxeKwxGPO0Te/4XyXLCVt7G4Ssg9YTxy/Qf6173Gg+aCch/BaNBaZjiaopKJTyah5P1qEA6Z6p3zmhz5sCvCailhSeU+A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=mUTBrM0j; arc=none smtp.client-ip=209.85.216.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mUTBrM0j" Received: by mail-pj1-f44.google.com with SMTP id 98e67ed59e1d1-35da9c0c007so4850378a91.2 for ; Tue, 07 Apr 2026 07:32:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775572341; x=1776177141; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PY3ak4gklrB7dT78Kl3RlnvUvqFrPFBtFQWCDk/TdtE=; b=mUTBrM0jPWT+E9zdBLjqSUY5J6GS5B/0t8yP1lR0KNqMcyDEadYJMasDpBu53tN2OJ x80B5u3LbWKc+6mRhxBWv0/8LaTLoeSKFfjISLWflQPnmCNaoSBUjbjM6kdKx0urG/9N OniV2NJP4PFoUxwfvJTv8SpcyrRpsMVN7kMhMiqFQ4EN7eWi6cCWDk/ef79g1WpYuzse oahVehzYq+JxPhWy0o6+0dwyqg5WnONojTX50mjojafBsPx87l47QfGdoiKnU/MYnFjA 6lHmtiZuYU2RVhs/0+dk/JZLyLDjs26yX6PTNQRP21Jn8eNkzad46uIhJBqpQy4WZSuO KOPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775572341; x=1776177141; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=PY3ak4gklrB7dT78Kl3RlnvUvqFrPFBtFQWCDk/TdtE=; b=sd/R4WDqbQpAw/OxYVfY2xnRbJlzm8VxwhNYFtCQqzoD6LQxMwHGI0HReuCq7FUYui 2AkyST7V0u0jAFPjlvertfyoTnR/jw6eO5In4pBuaNdgwVbSXHYCGi+af6KLuo43A2xC dUkRA2kecVuPxmAZQQd1cWGeqpRSfcGuFlWGwsEUFXMKkIZ5EVlKCm+ltky3TA61+DB8 kWZ+rJsZmerL4XSlnmQGDAPdnC+Ozqvo9vZYX8W3gBp0cKWTBh+I9vXCeJSUTFsLfh7J MYqj2250N1bJrgm4TMBA6FxzogaHWGmE0D4n6r4BVcluNhZEPjDny9s4Eat6sJEcBbLJ awnQ== X-Forwarded-Encrypted: i=1; AJvYcCULT0w1XzPDCudlyAXtWZlHOoNdjwlbV8zuLuEK6qK78qcAdkKl0xFj9SvL4BMrQZieQbOgwSpjtzs1clk=@vger.kernel.org X-Gm-Message-State: AOJu0YwSSyq9NewM+wHZgWkiZKmkr6ATJnr5e9nztjoy592HNTbfAKPB DOFwnk2o53kSANIj57KInQRvHOgHCYajjj9/7x6f65g+5Kw0SsbLarAC X-Gm-Gg: AeBDievS3dYSnZxvqo3sf/QQ968IWO3E7MH+N4xj/SeD/VGzILLT6XCZk4ND6Dx8VLo xWz4z4bAfBG7geGQE5QuCZpfdTAEeQnuc0Vz8Mgogb2dAcasQEsMiose+Chymg9dVoeQDk/8/n/ jEpc7fucZ8ghplbH1MruiJFzvGmMS2SF/BdyuZeiyItbnHEUUWa3rAkoJI2dPK/RIvnQWeAFMMz KX2fXfqy7pw0v3wPWctK5avROqhhxi7rGa3atNzyNr5mjOwopI9hogD0XeQfTkaymLbX/ixrMAw a+vtRX3bGAFioErt4z6B0yBrW0QUg1w42yJyhCJvUVPqgt0+hA96fm54wCkyq26nXcZaCpgwwNK dG2mnKZCRtWipsqieK0N2qEppnRpgqG+wRgnGOKR3o8muFF8qI8u7aIz+eGQZ7juLDneZPfHD1r fR0HCPJ+g7Lvy7JyLG/6rDX9pHFjOQv20do1gFMuG7imcDtxDDB6F6kSj7I+S+ X-Received: by 2002:a17:903:8c5:b0:2b2:4d36:7aa with SMTP id d9443c01a7336-2b281932d71mr188155645ad.35.1775572341300; Tue, 07 Apr 2026 07:32:21 -0700 (PDT) Received: from Mac.localdomain.com ([49.205.216.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b2749cbc58sm181201525ad.78.2026.04.07.07.32.17 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 07 Apr 2026 07:32:20 -0700 (PDT) From: "Ritesh Harjani (IBM)" To: linuxppc-dev@lists.ozlabs.org, Haren Myneni Cc: Madhavan Srinivasan , Christophe Leroy , Venkat Rao Bagalkote , Nicholas Piggin , linux-kernel@vger.kernel.org, "Ritesh Harjani (IBM)" Subject: [RFC v1 6/6] pseries/papr-hvpipe: Simplify error handling in papr_hvpipe_init() Date: Tue, 7 Apr 2026 20:01:40 +0530 Message-ID: <15828cd5a57af373fa2e7025bdb7ef0d0a1143bb.1775569027.git.ritesh.list@gmail.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Remove such 3 levels of nesting patterns to check success return values from function calls. ret =3D enable_hvpipe_IRQ() if (!ret) ret =3D set_hvpipe_sys_param(1) if (!ret) ret =3D misc_register() Instead just bail out to "out*:" labels, in case of any error. This simplifies the init flow. Signed-off-by: Ritesh Harjani (IBM) --- arch/powerpc/platforms/pseries/papr-hvpipe.c | 26 +++++++++++--------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/arch/powerpc/platforms/pseries/papr-hvpipe.c b/arch/powerpc/pl= atforms/pseries/papr-hvpipe.c index f41f5c0a8418..03ec004a6701 100644 --- a/arch/powerpc/platforms/pseries/papr-hvpipe.c +++ b/arch/powerpc/platforms/pseries/papr-hvpipe.c @@ -768,23 +768,27 @@ static int __init papr_hvpipe_init(void) } ret =3D enable_hvpipe_IRQ(); - if (!ret) { - ret =3D set_hvpipe_sys_param(1); - if (!ret) - ret =3D misc_register(&papr_hvpipe_dev); - } + if (ret) + goto out_wq; - if (!ret) { - pr_info("hvpipe feature is enabled\n"); - hvpipe_feature =3D true; - return 0; - } + ret =3D set_hvpipe_sys_param(1); + if (ret) + goto out_wq; - pr_err("hvpipe feature is not enabled %d\n", ret); + ret =3D misc_register(&papr_hvpipe_dev); + if (ret) + goto out_wq; + + pr_info("hvpipe feature is enabled\n"); + hvpipe_feature =3D true; + return 0; + +out_wq: destroy_workqueue(papr_hvpipe_wq); out: kfree(papr_hvpipe_work); papr_hvpipe_work =3D NULL; + pr_err("hvpipe feature is not enabled %d\n", ret); return ret; } machine_device_initcall(pseries, papr_hvpipe_init); -- 2.39.5