linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] paride/pcd: need to check if cd->disk is null in pcd_detect
@ 2019-08-13 11:23 zhengbin
  2019-09-04  8:40 ` zhengbin (A)
  2019-09-04 13:04 ` Jens Axboe
  0 siblings, 2 replies; 3+ messages in thread
From: zhengbin @ 2019-08-13 11:23 UTC (permalink / raw)
  To: tim, axboe, linux-block; +Cc: yi.zhang, zhengbin13

If alloc_disk fails in pcd_init_units, cd->disk & pi are empty, we need
to check if cd->disk is null in pcd_detect.

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: zhengbin <zhengbin13@huawei.com>
---
 drivers/block/paride/pcd.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/block/paride/pcd.c b/drivers/block/paride/pcd.c
index bfca80d..636bfea 100644
--- a/drivers/block/paride/pcd.c
+++ b/drivers/block/paride/pcd.c
@@ -723,9 +723,9 @@ static int pcd_detect(void)
 	k = 0;
 	if (pcd_drive_count == 0) { /* nothing spec'd - so autoprobe for 1 */
 		cd = pcd;
-		if (pi_init(cd->pi, 1, -1, -1, -1, -1, -1, pcd_buffer,
-			    PI_PCD, verbose, cd->name)) {
-			if (!pcd_probe(cd, -1, id) && cd->disk) {
+		if (cd->disk && pi_init(cd->pi, 1, -1, -1, -1, -1, -1,
+			    pcd_buffer, PI_PCD, verbose, cd->name)) {
+			if (!pcd_probe(cd, -1, id)) {
 				cd->present = 1;
 				k++;
 			} else
@@ -736,11 +736,13 @@ static int pcd_detect(void)
 			int *conf = *drives[unit];
 			if (!conf[D_PRT])
 				continue;
+			if (!cd->disk)
+				continue;
 			if (!pi_init(cd->pi, 0, conf[D_PRT], conf[D_MOD],
 				     conf[D_UNI], conf[D_PRO], conf[D_DLY],
 				     pcd_buffer, PI_PCD, verbose, cd->name))
 				continue;
-			if (!pcd_probe(cd, conf[D_SLV], id) && cd->disk) {
+			if (!pcd_probe(cd, conf[D_SLV], id)) {
 				cd->present = 1;
 				k++;
 			} else
--
2.7.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] paride/pcd: need to check if cd->disk is null in pcd_detect
  2019-08-13 11:23 [PATCH] paride/pcd: need to check if cd->disk is null in pcd_detect zhengbin
@ 2019-09-04  8:40 ` zhengbin (A)
  2019-09-04 13:04 ` Jens Axboe
  1 sibling, 0 replies; 3+ messages in thread
From: zhengbin (A) @ 2019-09-04  8:40 UTC (permalink / raw)
  To: tim, axboe, linux-block; +Cc: yi.zhang

ping

On 2019/8/13 19:23, zhengbin wrote:
> If alloc_disk fails in pcd_init_units, cd->disk & pi are empty, we need
> to check if cd->disk is null in pcd_detect.
>
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: zhengbin <zhengbin13@huawei.com>
> ---
>  drivers/block/paride/pcd.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/block/paride/pcd.c b/drivers/block/paride/pcd.c
> index bfca80d..636bfea 100644
> --- a/drivers/block/paride/pcd.c
> +++ b/drivers/block/paride/pcd.c
> @@ -723,9 +723,9 @@ static int pcd_detect(void)
>  	k = 0;
>  	if (pcd_drive_count == 0) { /* nothing spec'd - so autoprobe for 1 */
>  		cd = pcd;
> -		if (pi_init(cd->pi, 1, -1, -1, -1, -1, -1, pcd_buffer,
> -			    PI_PCD, verbose, cd->name)) {
> -			if (!pcd_probe(cd, -1, id) && cd->disk) {
> +		if (cd->disk && pi_init(cd->pi, 1, -1, -1, -1, -1, -1,
> +			    pcd_buffer, PI_PCD, verbose, cd->name)) {
> +			if (!pcd_probe(cd, -1, id)) {
>  				cd->present = 1;
>  				k++;
>  			} else
> @@ -736,11 +736,13 @@ static int pcd_detect(void)
>  			int *conf = *drives[unit];
>  			if (!conf[D_PRT])
>  				continue;
> +			if (!cd->disk)
> +				continue;
>  			if (!pi_init(cd->pi, 0, conf[D_PRT], conf[D_MOD],
>  				     conf[D_UNI], conf[D_PRO], conf[D_DLY],
>  				     pcd_buffer, PI_PCD, verbose, cd->name))
>  				continue;
> -			if (!pcd_probe(cd, conf[D_SLV], id) && cd->disk) {
> +			if (!pcd_probe(cd, conf[D_SLV], id)) {
>  				cd->present = 1;
>  				k++;
>  			} else
> --
> 2.7.4
>
>
> .
>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] paride/pcd: need to check if cd->disk is null in pcd_detect
  2019-08-13 11:23 [PATCH] paride/pcd: need to check if cd->disk is null in pcd_detect zhengbin
  2019-09-04  8:40 ` zhengbin (A)
@ 2019-09-04 13:04 ` Jens Axboe
  1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2019-09-04 13:04 UTC (permalink / raw)
  To: zhengbin, tim, linux-block; +Cc: yi.zhang

On 8/13/19 5:23 AM, zhengbin wrote:
> If alloc_disk fails in pcd_init_units, cd->disk & pi are empty, we need
> to check if cd->disk is null in pcd_detect.

Applied, thanks.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-09-04 13:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-13 11:23 [PATCH] paride/pcd: need to check if cd->disk is null in pcd_detect zhengbin
2019-09-04  8:40 ` zhengbin (A)
2019-09-04 13:04 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).